locked
How to auto hide Xaml controls in WinRT

    Question

  • How can I hide some controls (ex: buttons) after period of time has elapsed and no user input has been detected? I need a behavior like scrolbars in ScrollViewer.

    Wednesday, February 27, 2013 10:00 AM

Answers

  • You can look at the ScrollBars template in C:\Program Files (x86)\Windows Kits\8.0\Include\WinRT\Xaml\Design\generic.xaml to see how it is handled there (the exact path may be slightly different if you are on x86 or if you installed the SDK elsewhere).

    What the ScrollBars do is to have visual states for the ScrollingIndicatorStates: TouchIndicator, MouseIndicator, and NoIndicator. In the code behind they determine what should be showing by tracking input and checking the type of input against the control's properties and then calling the VisualStateManager to go to the appropriate state. A timer can be run to shift back to NoIndicator if there hasn't been any user input.

    --Rob

    • Proposed as answer by Jesse Jiang Thursday, February 28, 2013 5:57 AM
    • Marked as answer by 55FRY Thursday, February 28, 2013 9:43 AM
    Wednesday, February 27, 2013 10:46 PM
    Owner

All replies

  • You can look at the ScrollBars template in C:\Program Files (x86)\Windows Kits\8.0\Include\WinRT\Xaml\Design\generic.xaml to see how it is handled there (the exact path may be slightly different if you are on x86 or if you installed the SDK elsewhere).

    What the ScrollBars do is to have visual states for the ScrollingIndicatorStates: TouchIndicator, MouseIndicator, and NoIndicator. In the code behind they determine what should be showing by tracking input and checking the type of input against the control's properties and then calling the VisualStateManager to go to the appropriate state. A timer can be run to shift back to NoIndicator if there hasn't been any user input.

    --Rob

    • Proposed as answer by Jesse Jiang Thursday, February 28, 2013 5:57 AM
    • Marked as answer by 55FRY Thursday, February 28, 2013 9:43 AM
    Wednesday, February 27, 2013 10:46 PM
    Owner
  • Thanks Rob, I have done as you suggested.
    Thursday, February 28, 2013 9:46 AM
  • Even though I'm late, this answer was exactly what I was looking for, thanks Rob!
    Saturday, May 25, 2013 11:29 AM