Zac*_*son 18 windows wpf xaml styles
我想使用XAML设置WPF按钮的样式,使其看起来像这些Windows 7通知区域弹出窗口的"混音器"和"更改日期和时间设置......"文本.
SystemColors的属性是否定义了该颜色?哪一个?
<Setter Property="Foreground"
Value="{DynamicResource {x:Static SystemColors.????}}" />
Run Code Online (Sandbox Code Playgroud)

Zac*_*son 29
我发现的最好的方法是实验和猜测.
我创建了一个小实用程序来可视化这些颜色.

<Window x:Class="SystemColors1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="System.Windows.SystemColors" Height="350" Width="525">
<Window.Resources>
<DataTemplate x:Key="CellColor">
<DockPanel>
<TextBlock>
<TextBlock.Background>
<SolidColorBrush Color="{Binding Path=Color}" />
</TextBlock.Background>
<TextBlock.Text>
     
     
     
</TextBlock.Text>
</TextBlock>
</DockPanel>
</DataTemplate>
</Window.Resources>
<Grid>
<ListView Grid.Row="1"
Name="SystemColorsList"
ItemsSource="{Binding}">
<ListView.View>
<GridView AllowsColumnReorder="True">
<GridViewColumn CellTemplate="{StaticResource CellColor}"
Header="Color"
Width="Auto"/>
<GridViewColumn DisplayMemberBinding="{Binding Path=Name}"
Header="Name"
Width="Auto"/>
</GridView>
</ListView.View>
</ListView>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
using System.Collections.Generic;
using System.Windows;
using System.Windows.Media;
using System.Reflection;
namespace SystemColors1
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
List<ColorAndName> l = new List<ColorAndName>();
foreach (PropertyInfo i in typeof(System.Windows.SystemColors).GetProperties())
{
if (i.PropertyType == typeof(Color))
{
ColorAndName cn = new ColorAndName();
cn.Color = (Color)i.GetValue(new Color(), BindingFlags.GetProperty, null, null, null);
cn.Name = i.Name;
l.Add(cn);
}
}
SystemColorsList.DataContext = l;
}
}
class ColorAndName
{
public Color Color { get; set; }
public string Name { get; set; }
}
}
Run Code Online (Sandbox Code Playgroud)
查看此SystemColors参考,特别是Aero Theme颜色.
文本会使用哪种颜色名称并不明显,但试图注视它,它看起来像HighlightBrush或MenuHighlightBrush可能是候选人......
| 归档时间: |
|
| 查看次数: |
14538 次 |
| 最近记录: |