C# Windows 7和Windows 8操作系统中WPF应用程序的呈现问题

C# Windows 7和Windows 8操作系统中WPF应用程序的呈现问题,c#,wpf,xaml,C#,Wpf,Xaml,以下XAML: <ProgressBar Height="10" BorderBrush="#898989" BorderThickness="2" Foreground="#f1592a" Background="#363636" Margin="15,0" VerticalAlignment="Center" HorizontalAlignment="Stretch" /> …生成以下样式: 如何解决渲染中的这种差异

以下XAML:

<ProgressBar Height="10" BorderBrush="#898989" BorderThickness="2" 
             Foreground="#f1592a" Background="#363636" Margin="15,0" 
             VerticalAlignment="Center" HorizontalAlignment="Stretch" />

…生成以下样式:

如何解决渲染中的这种差异

我试着用两种样式制作进度条,一种是从资源中创建的样式,另一种是内联样式,但仍然得到相同的行为。这是我使用和输出的xaml

<Window.Resources>
    <Style x:Key="ProgressStyleMy" TargetType="ProgressBar">

        <Setter Property="BorderBrush"  Value="#898989" ></Setter>

        <Setter Property="BorderThickness"  Value="2" ></Setter>

        <Setter Property="Foreground"  Value="#f1592a" ></Setter>
        <Setter Property="Background"  Value="#363636" ></Setter>

    </Style>
</Window.Resources>
<Grid>
    <StackPanel Background="Green">
        <StackPanel Orientation="Horizontal">
            <Button Margin="10" Click="Button_Click">Start</Button>
            <Button Margin="10" Click="Button_Click_1">Start2</Button>
        </StackPanel>


        <ProgressBar Value="{Binding Progress}" Height="10"  BorderBrush="#898989" BorderThickness="2" Foreground="#f1592a" Background="#363636"  Name="pgsbar"
                                            Margin="15,10" VerticalAlignment="Center" HorizontalAlignment="Stretch" >
        </ProgressBar>

        <ProgressBar Value="{Binding Progress}" Height="10"  Style="{StaticResource ResourceKey=ProgressStyleMy}" Name="pgsbar2"
                                            Margin="15,10"  >
        </ProgressBar>
    </StackPanel>
</Grid>

开始
开始2

您指的是Windows的外观和感觉。上图展示了Windows7提供的默认样式(Chrome),而下图(Metro)则与Windows8有关。如果要在Windows7中实现Metro外观,必须编辑控件模板

如果您不介意使用第三方资源,那么at上有很多Metro风格的控件。这里是GitHub链接:我认为这比自己尝试做要好,因为别人已经做过了

以下是工具箱中所有可用控件的列表:


单击所需的预览以及如何使其在应用程序中工作。

您的图像和标题指的是Windows 7,而问题中的文本指的是Windows 8和8.1。您能确认在Windows 7和Windows 8中得到不同的渲染吗?编辑控件模板意味着我使用了类似Style=“{staticResourceKey=customStyle}”的引用吗?还是别的什么?@JMat是的。使用
Blend
:@JMat检查我的编辑,以获得第三方工具包来帮助您。它是开源的。@JMat您必须更改的不仅仅是样式,还必须更改模板中的内容:@JMat是的,您必须编辑其模板。这不是很难。。。只需点击链接。