shi's profile白驹过隙PhotosBlogListsMore ![]() | Help |
|
June 08 Dump control's default Style Windows SDK provides sample styles for WPF common controls. (located at WinFX Development / Windows Presentation Foundation / Controls / Control Customization / Overviews). But it's not the real style. If you want to see the actual style of WPF controls, please try the following code (We use button as sample here):
Style style = FindResources(typeof(Button)) as Style; //Get button's default Style
if (style != null)
{ XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = new string(' ', 4); StringBuilder strbuild = new StringBuilder();
XmlWriter xmlwrite = XmlWriter.Create(strbuild, settings); XamlWriter.Save(style, xmlwrite);//Use XamlWriter to dump the style return strbuild.ToString();
} The basic idea is to use FindResources(typeof(<controlname>)) to get the control's default style, then use XamlWriter to dump the style to XAML code. TrackbacksThe trackback URL for this entry is: http://baishi9411.spaces.live.com/blog/cns!9198D7311EDA82B4!139.trak Weblogs that reference this entry
|
|
|