I have a slider element in my windows phone app which has min value=1 and max value=10 and by default the value is 1 when page loads. I want the value of the slider to be shown in a text block. so 1st I am storing the value of the slider in an integer when the values of slider changes using ValueChanged event. I have following code in this event handler.
private void complexitySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
int complexity;
complexity =(int)complexitySlider.Value; //<--null reference
}
but when I run my application, it shows the NullReference error. I have cross checked the name of the slider, its correct.
How can I remove this bug? I don’t want to directly bind the text block with slider value
well, it might help you to avoid NRE.