以下XAML:
<ProgressBar Height="10" BorderBrush="#898989" BorderThickness="2"
Foreground="#f1592a" Background="#363636" Margin="15,0"
VerticalAlignment="Center" HorizontalAlignment="Stretch" />
...生成以下样式:
如何在渲染中解决这种差异?
我尝试在2个样式中创建进度条,其中一个样式来自Resource,一个样式来自内联样式,BUt仍然获得相同的行为。这是我使用的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>
答案 0 :(得分:2)
您所指的是Windows外观。顶部图像演示了Windows 7提供的默认样式(Chrome),而底部图像(Metro)与Windows 8有关。如果要在Windows 7中实现Metro外观,则必须使用编辑控件模板。
如果您不介意第三方资源,那么http://mahapps.com/上有一组优秀的Metro风格控件。这里是GitHub链接:https://github.com/MahApps/MahApps.Metro我认为它比自己尝试更好,因为其他人已经完成了。
此处列出了工具包中可用的所有控件:http://mahapps.com/controls/
点击所需的预览,以及如何让它们在您的应用程序中运行。