wordpress   发布时间:2022-04-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了wpf – 如何使用正确的Windows系统颜色?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_675_2@

概述

我想使用XAML来设计 WPF按钮,看起来像这些 Windows 7通知区域弹出窗口中的“混音器”和“更改日期和时间设置…”文本. SystemColors的属性是否定义了该颜色?哪一个? <Setter Property="Foreground" Value="{Dynamicresource {x:Static SystemColors.????}}" /> 我发现的最好的方法
@H_675_2@
@H_675_2@ @H_675_2@
我想使用XAML来设计 WPF按钮,看起来像这些 Windows 7通知区域弹出窗口中的“混音器”和“更改日期和时间设置…”文本.

SystemColors属性是否定义了该颜色?哪一个

<Setter Property="Foreground"
        Value="{Dynamicresource {x:Static SystemColors.????}}" />
@H_675_2@
@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> 
                        &#160;&#160;&#160;&#160;&#160;
                        &#160;&#160;&#160;&#160;&#160;
                        &#160;&#160;&#160;&#160;&#160;
                    </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,请注明来意。