Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
“是否有一个标准的WPF样式表?”;微软";看?_Wpf_Wpf Controls - Fatal编程技术网

“是否有一个标准的WPF样式表?”;微软";看?

“是否有一个标准的WPF样式表?”;微软";看?,wpf,wpf-controls,Wpf,Wpf Controls,是否有一些经过修饰的样式表(及其使用指南)可以应用于任何窗口,使其具有适当的“Microsoft”外观 在我的例子中,我有一个简单的窗口: <Window x:Class="WPFTest.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" SnapsToDev

是否有一些经过修饰的样式表(及其使用指南)可以应用于任何窗口,使其具有适当的“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>
首先
它使窗口看起来是这样的:


它并不完美,但比没有应用样式时要好得多。

你可以在上找到微软的7个WPF主题。

谢谢,但这不是我需要的。我需要所有控件都有合适的大小和边距,而页面上的主题只会改变颜色。你找到解决方案了吗?我也对这个感兴趣。对于CSS,有几种常见的样式表用于最佳实践布局。