Skip to content

Instantly share code, notes, and snippets.

@ScottIsAFool
Created October 23, 2014 09:42
Show Gist options
  • Save ScottIsAFool/4ddc9d9e84f6c627d790 to your computer and use it in GitHub Desktop.
Save ScottIsAFool/4ddc9d9e84f6c627d790 to your computer and use it in GitHub Desktop.
Example of custom CommandBar
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