Alex Rivera | Logout

How do I use the correct Windows system colors?

Asked 2011-02-23T17:23:23.067
24

I want to use XAML to style a WPF button to look like the "Mixer" and "Change date and time settings..." text of these Windows 7 Notification area flyouts.

Does a property of SystemColors define that color? Which?

<Setter Property="Foreground"
        Value="{DynamicResource {x:Static SystemColors.????}}" />

Windows 7 Notification area flyout

Edit
Report

1 Answer

36

The best method I've found is experimentation and guessing.

I created a little utility to visualize these colors.

Interface

System.Windows.SystemColors

XAML

<Window x:Class="SystemColors1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="System.Windows.SystemColors" Height="350" Width="525">
    <Window.Resources>
        <DataTemplate x:Key="CellColor">
            <DockPanel>
                <TextBlock>
                    <TextBlock.Background>
                        <SolidColorBrush Color="{Binding Path=Color}" />
                    </TextBlock.Background>
                    <TextBlock.Text> 
                        &#160;&#160;&#160;&#160;&#160;
                        &#160;&#160;&#160;&#160;&#160;
                        &#160;&#160;&#160;&#160;&#160;
                    </TextBlock.Text>
                </TextBlock>
            </DockPanel>
        </DataTemplate>
    </Window.Resources>
    <Grid>
        <ListView Grid.Row="1"
                  Name="SystemColorsList"
                  ItemsSource="{Binding}">
            <ListView.View>
                <GridView AllowsColumnReorder="True">
                    <GridViewColumn CellTemplate="{StaticResource CellColor}"
                                    Header="Color"
                                    Width="Auto"/>
                    <GridViewColumn DisplayMemberBinding="{Binding Path=Name}"
                                    Header="Name"
                                    Width="Auto"/>
                </GridView>
            </ListView.View>
        </ListView>
    </Grid>
</Window>

                        
                        
answered 2011-02-24T19:35:29.843

Your Answer