wpf - How do I use the correct Windows system colors? -
i want use xaml style wpf button "mixer" , "change date , time settings..." text of these windows 7 notification area flyouts.
does property of systemcolors define color? which?
<setter property="foreground" value="{dynamicresource {x:static systemcolors.????}}" />
the best method i've found experimentation , guessing.
i created little utility visualize these colors.
interface
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 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; } } }
Comments
Post a Comment