大佬教程收集整理的这篇文章主要介绍了wpf – 如何使用正确的Windows系统颜色?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
SystemColors的属性是否定义了该颜色?哪一个?
<Setter Property="Foreground" Value="{Dynamicresource {x:Static SystemColors.????}}" />@H_675_2@
我创建了一个实用程序可视化这些颜色.
接口
XAML
<Window x:Class="SystemColors1.MainWindow" xmlns="http://scheR_949_11845@as.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://scheR_949_11845@as.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; } } }@H_675_2@@H_675_2@ @H_944_37@
以上是大佬教程为你收集整理的wpf – 如何使用正确的Windows系统颜色?全部内容,希望文章能够帮你解决wpf – 如何使用正确的Windows系统颜色?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。