是否有某些优秀的样式表(及其使用指南)可以应用于任何窗口以使其具有正确的“Microsoft”外观?
在我的案例/示例中,我有一个简单的窗口:
<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>
它的外观如下:
我可以想到以下样式组
<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>
与第一个复选框的此更改一起:
<CheckBox Margin="0">First</CheckBox>
它使窗口看起来像这样:
它并不完美,但它比未应用样式的要好得多。