2

It's not working in OnNavigatedTo but it works after OnNavigatedTo finishes.

protected override void OnNavigatedTo(Windows.UI.Xaml.Navigation.NavigationEventArgs e)
{
    base.OnNavigatedTo(e);
    //Here result is false
    bool result = VisualStateManager.GoToState(btn_reset, "Normal", false);
}


private void Button_Click(object sender, RoutedEventArgs e)
{
   //Here result is true
  bool result = VisualStateManager.GoToState(btn_reset, "Normal", false);
}

Any idea what's wrong in OnNavigatedTo I tried to set different states but they all are giving me same result.

I want to set the initial state in OnNavigatedTo method or before view is shown

1 Answer 1

2

I have written this code in Loaded event and it's working.

protected override void OnNavigatedTo(Windows.UI.Xaml.Navigation.NavigationEventArgs e)
{
    base.OnNavigatedTo(e);
    Loaded += ScreenLoaded;
}

private void ScreenLoaded(object sender, RoutedEventArgs e)
{
    btn_reset.IsEnabled = false;
    bool result = VisualStateManager.GoToState(btn_reset, "Normal", false);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.