wpf – 如何使用正确的Windows系统颜色?
发布时间:2020-12-13 20:13:11 所属栏目:Windows 来源:网络整理
导读:我想使用XAML来设计 WPF按钮,看起来像这些 Windows 7通知区域弹出窗口中的“混音器”和“更改日期和时间设置…”文本. SystemColors的属性是否定义了该颜色?哪一个? Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.????}}"
我想使用XAML来设计
WPF按钮,看起来像这些
Windows 7通知区域弹出窗口中的“混音器”和“更改日期和时间设置…”文本.
SystemColors的属性是否定义了该颜色?哪一个? <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.????}}" />
我发现的最好的方法是实验和猜测.
我创建了一个实用程序可视化这些颜色. 接口 XAML <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> C# 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); cn.Name = i.Name; l.Add(cn); } } SystemColorsList.DataContext = l; } } class ColorAndName { public Color Color { get; set; } public string Name { get; set; } } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- 网络打印机 – Windows – 从IP地址查找打印机名
- 环境变量 – 在Microsoft Visual Studio代码中不
- 使用Windows Azure作为文件存储系统的最佳策略是
- active-directory – Windows Server 2003 – 应
- Windows 10 子系统 Ubuntu 中安装 FastAdmin
- 如何使用Windows Active Directory身份验证和基于
- Windows 7 – 您可以在Windows 2012中使用VS 201
- windows-server-2008 – 远程管理网络策略服务器
- 在Windows上更改.docker目录
- windows – 如何在Inno Setup中使用Pascal变量?
热点阅读