Welcome to MSDN Blogs Sign in | Join | Help

Vincent Sibal's Blog

WPF Programming Topics
VS 2010 and .NET Framework 4.0 Beta1 are out now!

As many of you probably already know, dev10 beta1 is available for public download.  Some of the additions to Beta1 on the WPF Controls side include:

·         MultiTouch

·         EasingFunctions for animations

·         DataGrid, Calendar, DatePicker, and VisualStateManager in PresentationFramework.dll

·         New APIs to support the control local values bug

·         And tons of bug fixes on the new controls as well as existing control and element services areas

I’ll be going over some of these new features in more depth so stay tuned!

Posted: Thursday, May 21, 2009 7:54 AM by vinsibal
Filed under:

Comments

Patrick said:

I have been using the WPF Toolkit datagrid and have now started to use the .NET Framework 4 DataGrid in VS2010. Previously I used the Generic.xaml in my custom DataGrid from the supplied Toolkit source code. Where can I find the Generic.xaml file for the VS2010 implementation?

# June 20, 2009 10:18 AM

vinsibal said:

Patrick,

Unfortunately there isn't a Generic.xaml file that is available publically for the framework controls.  It is a nice thing to have in the toolkit.  There is a way you can get access to the default style programmatically.  Note that this is an internal method and undocumented so this can change in the future.

Here is some example code for retrieving the default style of a button.  This can obviously be replaced with any control.

Button b = new Button();

Assembly asm = Assembly.GetAssembly(typeof(Button));

Type styleHelperType = asm.GetType("System.Windows.StyleHelper");

Style style = (Style)styleHelperType.InvokeMember(

               "GetThemeStyle",

               BindingFlags.NonPublic | BindingFlags.InvokeMethod | BindingFlags.Static,

               null,

               null,

               new object[] { b, null });

var settings = new XmlWriterSettings();

settings.Indent = true;

var sb = new StringBuilder();

var writer = XmlWriter.Create(sb, settings);

XamlWriter.Save(style, writer);

MessageBox.Show(sb.ToString());

# June 24, 2009 8:38 AM

Patrick said:

Thank you very much for the help, it has got me the information I wanted. I understand that parts may change in the future (and most probably will). I will try to keep an eye out for that and cater for that possibility.

PS I'm sure I've seen similar approaches to this before, but maybe not quite the same. I need to learn a bit more about .NET in this area!

# June 24, 2009 3:30 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker