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?
null
. – John SaundersNullReferenceException
are the same. Please see "What is a NullReferenceException and how do I fix it?" for some hints. – John SaundersscoreFinal
you reference in theTextChanged
event is the same one as in the XAML. I think it is not. I have no idea how to reference controls which are inside of other controls in WPF, unless it's something likepivotPanel.scoreFinal
? – John Saunders