I'd like to bind all Windows.UI.Colors to a ListBox (ListView?) in a XAML Page, in a Universal Windows App (for Windows 10, in Visual Studio 2015).
I found this way to get all system colors:
Dictionary<string, Windows.UI.Color> Colors()
{
var _Colors = typeof(Windows.UI.Colors)
// using System.Reflection;
.GetRuntimeProperties()
.Select(c => new
{
Color = (Windows.UI.Color)c.GetValue(null),
Name = c.Name
});
return _Colors.ToDictionary(x => x.Name, x => x.Color);
}
I don't know how to bind it to a ListBox
<ListBox ItemsSource="{x:Bind colors}" >
</ListBox>
Ideally the list item text should be the color name, and the list item background the color value.
An alternative approach to #Romasz's answer:
Change the Color() method to a property, and return a dictionary with SolidColorBrush values instead of Color like so:
public Dictionary<string, SolidColorBrush> Colors
{
get
{
var _Colors = typeof(Windows.UI.Colors)
// using System.Reflection;
.GetRuntimeProperties()
.Select(c => new
{
Color = new SolidColorBrush((Windows.UI.Color)c.GetValue(null)),
Name = c.Name
});
return _Colors.ToDictionary(x => x.Name, x => x.Color);
}
}
Then, in the XAML, change the list box to this:
<ListBox ItemsSource="{x:Bind Colors}" >
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Background="{Binding Value}">
<TextBlock Text="{Binding Key}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
There is couple of things you need to improve about binding (and I would advise to read some more at MSDN). As for your code - in xaml you will need to declare how your ItemTemplate will look like and bind to a property within DataContext. You will also need probably a converter to convert Color to Brush:
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<ListView ItemsSource="{Binding MyColors}">
<ListView.Resources>
<local:ColorToBrush x:Key="ColorToBrush"/>
</ListView.Resources>
<ListView.ItemTemplate>
<DataTemplate>
<Border Background="{Binding Color, Converter={StaticResource ColorToBrush}}">
<TextBlock Text="{Binding Name}"/>
</Border>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>
And the code behind - converter class, the suitable property and setting DataContext in constructor:
public class ColorToBrush : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language) => new SolidColorBrush((Windows.UI.Color)value);
public object ConvertBack(object value, Type targetType, object parameter, string language) { throw new NotImplementedException(); }
}
public sealed partial class MainPage : Page
{
// this is the shortcut of {get { return ... }}
public Array MyColors => typeof(Windows.UI.Colors).GetRuntimeProperties()
.Select(c => new
{
Color = (Windows.UI.Color)c.GetValue(null),
Name = c.Name
}).ToArray();
public MainPage()
{
this.InitializeComponent();
DataContext = this;
}
}
Of course you can also bind to Dictionary, then you will have to exchange in XAML bindings: Name -> Key and Color -> Value.
public MainPage()
{
this.InitializeComponent();
this.Loaded += MainPage_Loaded;
}
private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
List<SystemColor> legacyBrushes = new List<SystemColor>();
foreach(var b in this.LegacyBrushes)
{
SystemColor c = new SystemColor();
c.ColorName = b;
c.ColorBrush = Application.Current.Resources[b] as SolidColorBrush;
legacyBrushes.Add(c);
}
foreach (var b in this.SystemBrushes)
{
SystemColor c = new SystemColor();
c.ColorName = b;
c.ColorBrush = Application.Current.Resources[b] as SolidColorBrush;
legacyBrushes.Add(c);
}
this._lvColors.ItemsSource = legacyBrushes;
}
public class SystemColor
{
public string ColorName { get; set; }
public SolidColorBrush ColorBrush { get; set; }
}
public string[] LegacyBrushes = new string[] {
"AppBarBackgroundThemeBrush",
"AppBarBorderThemeBrush",
"AppBarItemBackgroundThemeBrush",
"AppBarItemDisabledForegroundThemeBrush",
"AppBarItemForegroundThemeBrush",
"AppBarItemPointerOverBackgroundThemeBrush",
"AppBarItemPointerOverForegroundThemeBrush",
"AppBarItemPressedForegroundThemeBrush",
"AppBarSeparatorForegroundThemeBrush",
"AppBarToggleButtonCheckedBackgroundThemeBrush",
"AppBarToggleButtonCheckedBorderThemeBrush",
"AppBarToggleButtonCheckedDisabledBackgroundThemeBrush",
"AppBarToggleButtonCheckedDisabledBorderThemeBrush",
"AppBarToggleButtonCheckedDisabledForegroundThemeBrush",
"AppBarToggleButtonCheckedForegroundThemeBrush",
"AppBarToggleButtonCheckedPointerOverBackgroundThemeBrush",
"AppBarToggleButtonCheckedPointerOverBorderThemeBrush",
"AppBarToggleButtonCheckedPressedBackgroundThemeBrush",
"AppBarToggleButtonCheckedPressedBorderThemeBrush",
"AppBarToggleButtonCheckedPressedForegroundThemeBrush",
"AppBarToggleButtonPointerOverBackgroundThemeBrush",
"ApplicationForegroundThemeBrush",
"ApplicationHeaderForegroundThemeBrush",
"ApplicationPageBackgroundThemeBrush",
"ApplicationPointerOverForegroundThemeBrush",
"ApplicationPressedForegroundThemeBrush",
"ApplicationSecondaryForegroundThemeBrush",
"AutoSuggestBackgroundThemeBrush",
"BackButtonBackgroundThemeBrush",
"BackButtonDisabledForegroundThemeBrush",
"BackButtonForegroundThemeBrush",
"BackButtonPointerOverBackgroundThemeBrush",
"BackButtonPointerOverForegroundThemeBrush",
"BackButtonPressedForegroundThemeBrush",
"ButtonBackgroundThemeBrush",
"ButtonBorderThemeBrush",
"ButtonDisabledBackgroundThemeBrush",
"ButtonDisabledBorderThemeBrush",
"ButtonDisabledForegroundThemeBrush",
"ButtonForegroundThemeBrush",
"ButtonPointerOverBackgroundThemeBrush",
"ButtonPointerOverForegroundThemeBrush",
"ButtonPressedBackgroundThemeBrush",
"ButtonPressedForegroundThemeBrush",
"CheckBoxBackgroundThemeBrush",
"CheckBoxBorderThemeBrush",
"CheckBoxContentDisabledForegroundThemeBrush",
"CheckBoxContentForegroundThemeBrush",
"CheckBoxDisabledBackgroundThemeBrush",
"CheckBoxDisabledBorderThemeBrush",
"CheckBoxDisabledForegroundThemeBrush",
"CheckBoxForegroundThemeBrush",
"CheckBoxPointerOverBackgroundThemeBrush",
"CheckBoxPointerOverBorderThemeBrush",
"CheckBoxPointerOverForegroundThemeBrush",
"CheckBoxPressedBackgroundThemeBrush",
"CheckBoxPressedBorderThemeBrush",
"CheckBoxPressedForegroundThemeBrush",
"ComboBoxArrowDisabledForegroundThemeBrush",
"ComboBoxArrowForegroundThemeBrush",
"ComboBoxArrowPressedForegroundThemeBrush",
"ComboBoxBackgroundThemeBrush",
"ComboBoxBorderThemeBrush",
"ComboBoxDisabledBackgroundThemeBrush",
"ComboBoxDisabledBorderThemeBrush",
"ComboBoxDisabledForegroundThemeBrush",
"ComboBoxFocusedBackgroundThemeBrush",
"ComboBoxFocusedBorderThemeBrush",
"ComboBoxFocusedForegroundThemeBrush",
"ComboBoxForegroundThemeBrush",
"ComboBoxHeaderForegroundThemeBrush",
"ComboBoxItemDisabledForegroundThemeBrush",
"ComboBoxItemPointerOverBackgroundThemeBrush",
"ComboBoxItemPointerOverForegroundThemeBrush",
"ComboBoxItemPressedBackgroundThemeBrush",
"ComboBoxItemPressedForegroundThemeBrush",
"ComboBoxItemSelectedBackgroundThemeBrush",
"ComboBoxItemSelectedDisabledBackgroundThemeBrush",
"ComboBoxItemSelectedDisabledForegroundThemeBrush",
"ComboBoxItemSelectedForegroundThemeBrush",
"ComboBoxItemSelectedPointerOverBackgroundThemeBrush",
"ComboBoxPlaceholderTextForegroundThemeBrush",
"ComboBoxPointerOverBackgroundThemeBrush",
"ComboBoxPointerOverBorderThemeBrush",
"ComboBoxPopupBackgroundThemeBrush",
"ComboBoxPopupBorderThemeBrush",
"ComboBoxPopupForegroundThemeBrush",
"ComboBoxPressedBackgroundThemeBrush",
"ComboBoxPressedBorderThemeBrush",
"ComboBoxPressedHighlightThemeBrush",
"ComboBoxPressedForegroundThemeBrush",
"ComboBoxSelectedBackgroundThemeBrush",
"ComboBoxSelectedPointerOverBackgroundThemeBrush",
"ContentDialogBackgroundThemeBrush",
"ContentDialogBorderThemeBrush",
"ContentDialogContentForegroundBrush",
"ContentDialogDimmingThemeBrush",
"DatePickerHeaderForegroundThemeBrush",
"DatePickerForegroundThemeBrush",
"DefaultTextForegroundThemeBrush",
"FlipViewButtonBackgroundThemeBrush",
"FlipViewButtonBorderThemeBrush",
"FlipViewButtonForegroundThemeBrush",
"FlipViewButtonPointerOverBackgroundThemeBrush",
"FlipViewButtonPointerOverBorderThemeBrush",
"FlipViewButtonPointerOverForegroundThemeBrush",
"FlipViewButtonPressedBackgroundThemeBrush",
"FlipViewButtonPressedBorderThemeBrush",
"FlipViewButtonPressedForegroundThemeBrush",
"FlyoutBackgroundThemeBrush",
"FlyoutBorderThemeBrush",
"FocusVisualBlackStrokeThemeBrush",
"FocusVisualWhiteStrokeThemeBrush",
"HyperlinkButtonBackgroundThemeBrush",
"HyperlinkButtonBorderThemeBrush",
"HyperlinkDisabledThemeBrush",
"HyperlinkForegroundThemeBrush",
"HyperlinkPointerOverForegroundThemeBrush",
"HyperlinkPressedForegroundThemeBrush",
"HubSectionHeaderPointerOverForegroundThemeBrush",
"HubSectionHeaderPressedForegroundThemeBrush",
"IMECandidateBackgroundThemeBrush",
"IMECandidateForegroundThemeBrush",
"IMECandidatePointerOverBackgroundThemeBrush",
"IMECandidatePointerOverForegroundThemeBrush",
"IMECandidateSecondaryForegroundThemeBrush",
"IMECandidateSelectedBackgroundThemeBrush",
"IMECandidateSelectedForegroundThemeBrush",
"IMECandidateListBackgroundThemeBrush",
"IMECandidateListPagingButtonBackgroundThemeBrush",
"IMECandidateListPagingButtonBorderThemeBrush",
"IMECandidateListPagingButtonForegroundThemeBrush",
"IMECandidateListPagingButtonPointerOverBackgroundThemeBrush",
"IMECandidateListPagingButtonPointerOverForegroundThemeBrush",
"IMECandidateListPagingButtonPressedBackgroundThemeBrush",
"IMECandidateListPagingButtonPressedForegroundThemeBrush",
"JumpListDefaultEnabledForeground",
"JumpListDefaultEnabledBackground",
"JumpListDefaultDisabledForeground",
"JumpListDefaultDisabledBackground",
"ListBoxBackgroundThemeBrush",
"ListBoxBorderThemeBrush",
"ListBoxDisabledForegroundThemeBrush",
"ListBoxFocusBackgroundThemeBrush",
"ListBoxForegroundThemeBrush",
"ListBoxItemDisabledForegroundThemeBrush",
"ListBoxItemPointerOverBackgroundThemeBrush",
"ListBoxItemPointerOverForegroundThemeBrush",
"ListBoxItemPressedBackgroundThemeBrush",
"ListBoxItemPressedForegroundThemeBrush",
"ListBoxItemSelectedBackgroundThemeBrush",
"ListBoxItemSelectedDisabledBackgroundThemeBrush",
"ListBoxItemSelectedDisabledForegroundThemeBrush",
"ListBoxItemSelectedForegroundThemeBrush",
"ListBoxItemSelectedPointerOverBackgroundThemeBrush",
"ListPickerFlyoutPresenterSelectedItemForegroundThemeBrush",
"ListPickerFlyoutPresenterSelectedItemBackgroundThemeBrush",
"ListViewGroupHeaderForegroundThemeBrush",
"ListViewGroupHeaderPointerOverForegroundThemeBrush",
"ListViewGroupHeaderPressedForegroundThemeBrush",
"ListViewItemCheckHintThemeBrush",
"ListViewItemCheckSelectingThemeBrush",
"ListViewItemCheckThemeBrush",
"ListViewItemDragBackgroundThemeBrush",
"ListViewItemDragForegroundThemeBrush",
"ListViewItemFocusBorderThemeBrush",
"ListViewItemOverlayBackgroundThemeBrush",
"ListViewItemOverlayForegroundThemeBrush",
"ListViewItemOverlaySecondaryForegroundThemeBrush",
"ListViewItemPlaceholderBackgroundThemeBrush",
"ListViewItemPointerOverBackgroundThemeBrush",
"ListViewItemSelectedBackgroundThemeBrush",
"ListViewItemSelectedForegroundThemeBrush",
"ListViewItemSelectedPointerOverBackgroundThemeBrush",
"ListViewItemSelectedPointerOverBorderThemeBrush",
"LoopingSelectorForegroundThemeBrush",
"LoopingSelectorSelectionBackgroundThemeBrush",
"LoopingSelectorSelectionForegroundThemeBrush",
"MediaButtonForegroundThemeBrush",
"MediaButtonBackgroundThemeBrush",
"MediaButtonPointerOverForegroundThemeBrush",
"MediaButtonPointerOverBackgroundThemeBrush",
"MediaButtonPressedForegroundThemeBrush",
"MediaButtonPressedBackgroundThemeBrush",
"MediaButtonPressedBorderThemeBrush",
"MediaControlPanelVideoThemeBrush",
"MediaControlPanelAudioThemeBrush",
"MediaDownloadProgressIndicatorThemeBrush",
"MediaErrorBackgroundThemeBrush",
"MediaTextThemeBrush",
"MenuFlyoutItemFocusedBackgroundThemeBrush",
"MenuFlyoutItemFocusedForegroundThemeBrush",
"MenuFlyoutItemDisabledForegroundThemeBrush",
"MenuFlyoutItemPointerOverBackgroundThemeBrush",
"MenuFlyoutItemPointerOverForegroundThemeBrush",
"MenuFlyoutItemPressedBackgroundThemeBrush",
"MenuFlyoutItemPressedForegroundThemeBrush",
"PivotForegroundThemeBrush",
"PivotHeaderBackgroundSelectedBrush",
"PivotHeaderBackgroundUnselectedBrush",
"PivotHeaderForegroundSelectedBrush",
"PivotHeaderForegroundUnselectedBrush",
"PivotNavButtonBackgroundThemeBrush",
"PivotNavButtonBorderThemeBrush",
"PivotNavButtonForegroundThemeBrush",
"PivotNavButtonPointerOverBackgroundThemeBrush",
"PivotNavButtonPointerOverBorderThemeBrush",
"PivotNavButtonPointerOverForegroundThemeBrush",
"PivotNavButtonPressedBackgroundThemeBrush",
"PivotNavButtonPressedBorderThemeBrush",
"PivotNavButtonPressedForegroundThemeBrush",
"MenuFlyoutSeparatorThemeBrush",
"ProgressBarBackgroundThemeBrush",
"ProgressBarBorderThemeBrush",
"ProgressBarForegroundThemeBrush",
"ProgressBarIndeterminateForegroundThemeBrush",
"RadioButtonBackgroundThemeBrush",
"RadioButtonBorderThemeBrush",
"RadioButtonContentDisabledForegroundThemeBrush",
"RadioButtonContentForegroundThemeBrush",
"RadioButtonDisabledBackgroundThemeBrush",
"RadioButtonDisabledBorderThemeBrush",
"RadioButtonDisabledForegroundThemeBrush",
"RadioButtonForegroundThemeBrush",
"RadioButtonPointerOverBackgroundThemeBrush",
"RadioButtonPointerOverBorderThemeBrush",
"RadioButtonPointerOverForegroundThemeBrush",
"RadioButtonPressedBackgroundThemeBrush",
"RadioButtonPressedBorderThemeBrush",
"RadioButtonPressedForegroundThemeBrush",
"RepeatButtonBorderThemeBrush",
"RepeatButtonDisabledBackgroundThemeBrush",
"RepeatButtonDisabledBorderThemeBrush",
"RepeatButtonDisabledForegroundThemeBrush",
"RepeatButtonForegroundThemeBrush",
"RepeatButtonPointerOverBackgroundThemeBrush",
"RepeatButtonPointerOverForegroundThemeBrush",
"RepeatButtonPressedBackgroundThemeBrush",
"RepeatButtonPressedForegroundThemeBrush",
"ScrollBarButtonForegroundThemeBrush",
"ScrollBarButtonPointerOverBackgroundThemeBrush",
"ScrollBarButtonPointerOverBorderThemeBrush",
"ScrollBarButtonPointerOverForegroundThemeBrush",
"ScrollBarButtonPressedBackgroundThemeBrush",
"ScrollBarButtonPressedBorderThemeBrush",
"ScrollBarButtonPressedForegroundThemeBrush",
"ScrollBarPanningBackgroundThemeBrush",
"ScrollBarPanningBorderThemeBrush",
"ScrollBarThumbBackgroundThemeBrush",
"ScrollBarThumbBorderThemeBrush",
"ScrollBarThumbPointerOverBackgroundThemeBrush",
"ScrollBarThumbPointerOverBorderThemeBrush",
"ScrollBarThumbPressedBackgroundThemeBrush",
"ScrollBarThumbPressedBorderThemeBrush",
"ScrollBarTrackBackgroundThemeBrush",
"ScrollBarTrackBorderThemeBrush",
"SearchBoxBackgroundThemeBrush",
"SearchBoxBorderThemeBrush",
"SearchBoxDisabledBackgroundThemeBrush",
"SearchBoxDisabledTextThemeBrush",
"SearchBoxDisabledBorderThemeBrush",
"SearchBoxPointerOverBackgroundThemeBrush",
"SearchBoxPointerOverTextThemeBrush",
"SearchBoxPointerOverBorderThemeBrush",
"SearchBoxFocusedBackgroundThemeBrush",
"SearchBoxFocusedTextThemeBrush",
"SearchBoxFocusedBorderThemeBrush",
"SearchBoxButtonBackgroundThemeBrush",
"SearchBoxButtonForegroundThemeBrush",
"SearchBoxButtonPointerOverForegroundThemeBrush",
"SearchBoxButtonPointerOverBackgroundThemeBrush",
"SearchBoxSeparatorSuggestionForegroundThemeBrush",
"SearchBoxHitHighlightForegroundThemeBrush",
"SearchBoxHitHighlightSelectedForegroundThemeBrush",
"SearchBoxIMECandidateListSeparatorThemeBrush",
"SearchBoxForegroundThemeBrush",
"SemanticZoomButtonBackgroundThemeBrush",
"SemanticZoomButtonBorderThemeBrush",
"SemanticZoomButtonForegroundThemeBrush",
"SemanticZoomButtonPointerOverBackgroundThemeBrush",
"SemanticZoomButtonPointerOverBorderThemeBrush",
"SemanticZoomButtonPointerOverForegroundThemeBrush",
"SemanticZoomButtonPressedBackgroundThemeBrush",
"SemanticZoomButtonPressedBorderThemeBrush",
"SemanticZoomButtonPressedForegroundThemeBrush",
"SettingsFlyoutBackgroundThemeBrush",
"SettingsFlyoutBackButtonPointerOverBackgroundThemeBrush",
"SettingsFlyoutHeaderBackgroundThemeBrush",
"SettingsFlyoutHeaderForegroundThemeBrush",
"SliderBorderThemeBrush",
"SliderDisabledBorderThemeBrush",
"SliderThumbBackgroundThemeBrush",
"SliderThumbBorderThemeBrush",
"SliderThumbDisabledBackgroundThemeBrush",
"SliderThumbPointerOverBackgroundThemeBrush",
"SliderThumbPointerOverBorderThemeBrush",
"SliderThumbPressedBackgroundThemeBrush",
"SliderThumbPressedBorderThemeBrush",
"SliderTickMarkInlineBackgroundThemeBrush",
"SliderTickMarkInlineDisabledForegroundThemeBrush",
"SliderTickmarkOutsideBackgroundThemeBrush",
"SliderTickMarkOutsideDisabledForegroundThemeBrush",
"SliderTrackBackgroundThemeBrush",
"SliderTrackDecreaseBackgroundThemeBrush",
"SliderTrackDecreaseDisabledBackgroundThemeBrush",
"SliderTrackDecreasePointerOverBackgroundThemeBrush",
"SliderTrackDecreasePressedBackgroundThemeBrush",
"SliderTrackDisabledBackgroundThemeBrush",
"SliderTrackPointerOverBackgroundThemeBrush",
"SliderTrackPressedBackgroundThemeBrush",
"SliderHeaderForegroundThemeBrush",
"TextBoxForegroundHeaderThemeBrush",
"TextBoxPlaceholderTextThemeBrush",
"TextBoxBackgroundThemeBrush",
"TextSelectionHighlightColorThemeBrush",
"TextBoxBorderThemeBrush",
"TextBoxButtonBackgroundThemeBrush",
"TextBoxButtonBorderThemeBrush",
"TextBoxButtonForegroundThemeBrush",
"TextBoxButtonPointerOverBackgroundThemeBrush",
"TextBoxButtonPointerOverBorderThemeBrush",
"TextBoxButtonPointerOverForegroundThemeBrush",
"TextBoxButtonPressedBackgroundThemeBrush",
"TextBoxButtonPressedBorderThemeBrush",
"TextBoxButtonPressedForegroundThemeBrush",
"TextBoxDisabledBackgroundThemeBrush",
"TextBoxDisabledBorderThemeBrush",
"TextBoxDisabledForegroundThemeBrush",
"TextBoxForegroundThemeBrush",
"ThumbBackgroundThemeBrush",
"ThumbBorderThemeBrush",
"ThumbPointerOverBackgroundThemeBrush",
"ThumbPointerOverBorderThemeBrush",
"ThumbPressedBackgroundThemeBrush",
"ThumbPressedBorderThemeBrush",
"TimePickerHeaderForegroundThemeBrush",
"TimePickerForegroundThemeBrush",
"ToggleButtonBackgroundThemeBrush",
"ToggleButtonBorderThemeBrush",
"ToggleButtonCheckedBackgroundThemeBrush",
"ToggleButtonCheckedBorderThemeBrush",
"ToggleButtonCheckedDisabledBackgroundThemeBrush",
"ToggleButtonCheckedDisabledForegroundThemeBrush",
"ToggleButtonCheckedForegroundThemeBrush",
"ToggleButtonCheckedPointerOverBackgroundThemeBrush",
"ToggleButtonCheckedPointerOverBorderThemeBrush",
"ToggleButtonCheckedPressedBackgroundThemeBrush",
"ToggleButtonCheckedPressedBorderThemeBrush",
"ToggleButtonCheckedPressedForegroundThemeBrush",
"ToggleButtonDisabledBorderThemeBrush",
"ToggleButtonDisabledForegroundThemeBrush",
"ToggleButtonForegroundThemeBrush",
"ToggleButtonPointerOverBackgroundThemeBrush",
"ToggleButtonPressedBackgroundThemeBrush",
"ToggleButtonPressedForegroundThemeBrush",
"ToggleSwitchCurtainBackgroundThemeBrush",
"ToggleSwitchCurtainDisabledBackgroundThemeBrush",
"ToggleSwitchCurtainPointerOverBackgroundThemeBrush",
"ToggleSwitchCurtainPressedBackgroundThemeBrush",
"ToggleSwitchDisabledForegroundThemeBrush",
"ToggleSwitchForegroundThemeBrush",
"ToggleSwitchHeaderDisabledForegroundThemeBrush",
"ToggleSwitchHeaderForegroundThemeBrush",
"ToggleSwitchOuterBorderBorderThemeBrush",
"ToggleSwitchOuterBorderDisabledBorderThemeBrush",
"ToggleSwitchThumbBackgroundThemeBrush",
"ToggleSwitchThumbBorderThemeBrush",
"ToggleSwitchThumbDisabledBackgroundThemeBrush",
"ToggleSwitchThumbDisabledBorderThemeBrush",
"ToggleSwitchThumbPointerOverBackgroundThemeBrush",
"ToggleSwitchThumbPointerOverBorderThemeBrush",
"ToggleSwitchThumbPressedBackgroundThemeBrush",
"ToggleSwitchThumbPressedForegroundThemeBrush",
"ToggleSwitchTrackBackgroundThemeBrush",
"ToggleSwitchTrackBorderThemeBrush",
"ToggleSwitchTrackDisabledBackgroundThemeBrush",
"ToggleSwitchTrackPointerOverBackgroundThemeBrush",
"ToggleSwitchTrackPressedBackgroundThemeBrush",
"ToolTipBackgroundThemeBrush",
"ToolTipBorderThemeBrush",
"ToolTipForegroundThemeBrush",
};
public string[] SystemBrushes = new string[] {
"SystemControlBackgroundAccentBrush",
"SystemControlBackgroundAltHighBrush",
"SystemControlBackgroundAltMediumHighBrush",
"SystemControlBackgroundAltMediumLowBrush",
"SystemControlBackgroundBaseHighBrush",
"SystemControlBackgroundBaseLowBrush",
"SystemControlBackgroundBaseMediumBrush",
"SystemControlBackgroundBaseMediumHighBrush",
"SystemControlBackgroundBaseMediumLowBrush",
"SystemControlBackgroundChromeBlackHighBrush",
"SystemControlBackgroundChromeBlackMediumBrush",
"SystemControlBackgroundChromeMediumBrush",
"SystemControlBackgroundChromeMediumLowBrush",
"SystemControlBackgroundChromeWhiteBrush",
"SystemControlBackgroundListLowBrush",
"SystemControlBackgroundListMediumBrush",
"SystemControlDisabledAccentBrush",
"SystemControlDisabledBaseHighBrush",
"SystemControlDisabledBaseLowBrush",
"SystemControlDisabledBaseMediumLowBrush",
"SystemControlDisabledChromeDisabledHighBrush",
"SystemControlDisabledChromeDisabledLowBrush",
"SystemControlDisabledChromeHighBrush",
"SystemControlDisabledChromeMediumLowBrush",
"SystemControlDisabledListMediumBrush",
"SystemControlDisabledTransparentBrush",
"SystemControlForegroundAccentBrush",
"SystemControlForegroundAltHighBrush",
"SystemControlForegroundAltMediumHighBrush",
"SystemControlForegroundBaseHighBrush",
"SystemControlForegroundBaseLowBrush",
"SystemControlForegroundBaseMediumBrush",
"SystemControlForegroundBaseMediumHighBrush",
"SystemControlForegroundBaseMediumLowBrush",
"SystemControlForegroundChromeBlackHighBrush",
"SystemControlForegroundChromeHighBrush",
"SystemControlForegroundChromeMediumBrush",
"SystemControlForegroundChromeWhiteBrush",
"SystemControlForegroundChromeDisabledLowBrush",
"SystemControlForegroundListLowBrush",
"SystemControlForegroundListMediumBrush",
"SystemControlForegroundTransparentBrush",
"SystemControlForegroundChromeBlackMediumBrush",
"SystemControlForegroundChromeBlackMediumLowBrush",
"SystemControlHighlightAccentBrush",
"SystemControlHighlightAltAccentBrush",
"SystemControlHighlightAltAltHighBrush",
"SystemControlHighlightAltBaseHighBrush",
"SystemControlHighlightAltBaseLowBrush",
"SystemControlHighlightAltBaseMediumBrush",
"SystemControlHighlightAltBaseMediumHighBrush",
"SystemControlHighlightAltAltMediumHighBrush",
"SystemControlHighlightAltBaseMediumLowBrush",
"SystemControlHighlightAltListAccentHighBrush",
"SystemControlHighlightAltListAccentLowBrush",
"SystemControlHighlightAltListAccentMediumBrush",
"SystemControlHighlightAltChromeWhiteBrush",
"SystemControlHighlightAltTransparentBrush",
"SystemControlHighlightBaseHighBrush",
"SystemControlHighlightBaseLowBrush",
"SystemControlHighlightBaseMediumBrush",
"SystemControlHighlightBaseMediumHighBrush",
"SystemControlHighlightBaseMediumLowBrush",
"SystemControlHighlightChromeAltLowBrush",
"SystemControlHighlightChromeHighBrush",
"SystemControlHighlightListAccentHighBrush",
"SystemControlHighlightListAccentLowBrush",
"SystemControlHighlightListAccentMediumBrush",
"SystemControlHighlightListMediumBrush",
"SystemControlHighlightListLowBrush",
"SystemControlHighlightTransparentBrush",
"SystemControlHyperlinkTextBrush",
"SystemControlHyperlinkBaseHighBrush",
"SystemControlHyperlinkBaseMediumBrush",
"SystemControlHyperlinkBaseMediumHighBrush",
"SystemControlPageBackgroundAltMediumBrush",
"SystemControlPageBackgroundMediumAltMediumBrush",
"SystemControlPageBackgroundBaseLowBrush",
"SystemControlPageBackgroundBaseMediumBrush",
"SystemControlPageBackgroundListLowBrush",
"SystemControlPageBackgroundChromeLowBrush",
"SystemControlPageTextBaseHighBrush",
"SystemControlPageTextBaseMediumBrush",
"SystemControlPageTextChromeBlackMediumLowBrush",
};
private void CheckBox_Checked(object sender, RoutedEventArgs e)
{
CheckBox cb = sender as CheckBox;
Frame rootFrame = Window.Current.Content as Frame;
rootFrame.RequestedTheme = cb.IsChecked.Value ? ElementTheme.Dark : ElementTheme.Light;
}
<ListView Name="_lvColors" SelectionMode="None" Margin="0 30 0 0">
<ListView.ItemTemplate>
<DataTemplate>
<Grid Height="48">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding ColorName}" VerticalAlignment="Center" IsTextSelectionEnabled="True" Margin="10 0"/>
<Grid Background="{Binding ColorBrush}" Grid.Column="1"/>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="Padding" Value="0" />
<Setter Property="Margin" Value="0" />
</Style>
</ListView.ItemContainerStyle>
</ListView>
<CheckBox Content="Theme" Checked="CheckBox_Checked" Unchecked="CheckBox_Checked" HorizontalAlignment="Center" VerticalAlignment="Top"/>