Reverse Engineering Styles in Avalon Using System.Windows.Serialization.Parser

A key tenet of Avalon is “lookless” controls: a button should simply be the idea of a button, not the actual button — very Platonic, really.  Now, the platform would not be very useful if all we provided was the idea of a button, so each content control does have a default style.  Here’s a nifty Avalon trick for finding out how the default styles were written, which can be very useful if you are looking to understand how to override that style and replace it with your own:

System.Windows.Controls.Control t = new System.Windows.Controls.TextBox();
s = t.Style;
using (StreamWriter sw = new StreamWriter(@”C:\Styles\TextBoxDefaultStyle.xaml”

Note that you could replace TextBox with any Avalon control.

Comments (4)

  1. PatriotB says:

    Let’s just hope that people USE the default styles. A common fear is that, since Avalon makes it easy to create such fancy UIs, that they will all be completely different and inconsistent. Hopefully developers will keep this in mind and use the defaults (which I assume are based on the user’s visual style).

  2. This looks like an useful tip – Avalon controls have a default style and you can get that information…

  3. I decided to try and improve the look of my Sandbox3D by opening and styling it in Expression Interactive…