0

I have several GroupBox controls, and all but one work fine. Code is the same, I don't see what the problem might be. I get NullReferenceException. Does anyone have any clue? This is XAML:

<GroupBox Header="Load neural network" Height="90" HorizontalAlignment="Left" Margin="416,34,0,0" Name="groupBox3" VerticalAlignment="Top" Width="207" IsEnabled="False">
    <Grid>
        <Button Content="Load" Height="23" HorizontalAlignment="Left" Margin="114,32,0,0" Name="loadBTN" VerticalAlignment="Top" Width="75" />
            <TextBox Height="23" HorizontalAlignment="Left" Margin="6,32,0,0" Name="textBox1" VerticalAlignment="Top" Width="93" />
    </Grid>
</GroupBox>

And this is code behind where error pops up:

private void loadRBcheck_Checked(object sender, RoutedEventArgs e)
{
    newRBcheck.IsChecked = false;
    groupBox1.IsEnabled = false;
    groupBox2.IsEnabled = false;
    inputTB.IsEnabled = false;
    hiddenTB.IsEnabled = false;
    outputTB.IsEnabled = false;
    groupBox3.IsEnabled = true; //this line causes error
    label1.IsEnabled = false;
    label2.IsEnabled = false;
    label3.IsEnabled = false;
}
H.B.
  • 166,899
  • 29
  • 327
  • 400
Dr_Freeman
  • 261
  • 1
  • 5
  • 12
  • Are you creating a variable groupBox3 in code someplace? or are you seetting it to null some where? – Anuraj Aug 06 '12 at 11:49
  • Or is it possible groupBox3 is inside a container that uses Virtualization and it hasn't been loaded yet? In the Loaded event of your Window/Control is groupBox3 null? – Brian S Aug 07 '12 at 12:03

0 Answers0