I'm Currently Working on a windows 8.1 Application and im trying to set the value of a textblock that is inside of a Pivot Page.
When I try to set the value of the text Block I get a weird error about a Null Refrence Exception.
The Code for the XAML is as follows
<TextBlock x:Name="scoreFinal" Text="0" HorizontalAlignment="Left" Margin="235,408,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="34" Width="97" FontSize="32"/>
Im using an event Handler for TextChanged in a textbox to change the value of the TextBlock
using the following code
private void score_TextChanged(object sender, TextChangedEventArgs e)
{
int totalPar=38;
int actual=0;
// actual = int.Parse(score1.Text) + int.Parse(score2.Text) + int.Parse(score3.Text) + int.Parse(score4.Text) + int.Parse(score5.Text) + int.Parse(score6.Text) + int.Parse(score7.Text) + int.Parse(score8.Text) + int.Parse(score9.Text);
if (actual < totalPar)
{
scoreFinal.Text = ("-" + (totalPar - actual));
}
When I run the page it loads fine and I have values on all my text boxes to be 0
but when i run this and edit text I get the following error
Anyone got a clue?
Copyright Notice:Content Author:「Hunter」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/30043384/windows-phone-8-1-nullrefrenceexception