Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a standard WPF stylesheet for a "Microsoft" look?

Is there somewhere some polished stylesheet (and guidelines for its usage) that can be applied to any window to give it a proper "Microsoft" look?

In my case / example I have a simple window:

<Window x:Class="WPFTest.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    SnapsToDevicePixels="True">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <GroupBox Header="My checkboxes">
          <StackPanel >
                <CheckBox>First</CheckBox>
                <CheckBox>Second</CheckBox>
                <CheckBox>Third</CheckBox>
            </StackPanel>
        </GroupBox>
        <StackPanel Grid.Row="1" Grid.ColumnSpan="2"
                    Orientation="Horizontal"
                    HorizontalAlignment="Right">
            <Button>OK</Button>
            <Button>Cancel</Button>
        </StackPanel>
    </Grid>
</Window>

This is how it looks:

I can think of the following styles group

<Window.Resources>
    <Style TargetType="CheckBox">
        <Setter Property="Margin" Value="0,8,0,0"/>
    </Style>
    <Style TargetType="Grid">
        <Setter Property="Margin" Value="8"/>
    </Style>
    <Style TargetType="StackPanel">
        <Setter Property="Margin" Value="0"/>
    </Style>
    <Style TargetType="GroupBox">
        <Setter Property="Padding" Value="8"/>
    </Style>
    <Style TargetType="Button">
        <Setter Property="Margin" Value="8,0,0,0"/>
        <Setter Property="Padding" Value="8"/>
        <Setter Property="MinWidth" Value="70"/>
    </Style>
</Window.Resources>

Together with this change of the first checkbox:

<CheckBox Margin="0">First</CheckBox>

It makes the window look this way:

It's not perfect, but it's much better than it was without styles applied.

like image 622
Mikhail Orlov Avatar asked Nov 05 '22 13:11

Mikhail Orlov


1 Answers

You could find 7 WPF Themes by Microsoft on WPF Toolkit page.

like image 187
Julien Hoarau Avatar answered Nov 15 '22 06:11

Julien Hoarau