Created
          October 23, 2014 09:42 
        
      - 
      
 - 
        
Save ScottIsAFool/4ddc9d9e84f6c627d790 to your computer and use it in GitHub Desktop.  
    Example of custom CommandBar
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | using Windows.UI.Xaml; | |
| using Windows.UI.Xaml.Controls; | |
| using Windows.UI.Xaml.Media; | |
| using MyApp.Extensions; | |
| namespace MyApp.Controls | |
| { | |
| public class CustomCommandBar : CommandBar | |
| { | |
| public CustomCommandBar() | |
| { | |
| Refresh(); | |
| } | |
| protected override void OnClosed(object e) | |
| { | |
| Refresh(); | |
| } | |
| protected override void OnOpened(object e) | |
| { | |
| Refresh(true); | |
| } | |
| public void Refresh(bool isOpen = false) | |
| { | |
| if (isOpen) | |
| { | |
| Background = Application.Current.GetThemeResource<SolidColorBrush>("AppBarOpenBrush"); | |
| Foreground = Application.Current.GetThemeResource<SolidColorBrush>("AltBackgroundBrush"); | |
| } | |
| else | |
| { | |
| Background = Application.Current.GetThemeResource<SolidColorBrush>("AltBackgroundBrush"); | |
| Foreground = Application.Current.GetThemeResource<SolidColorBrush>("AppBarOpenBrush"); | |
| } | |
| } | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment