tags:

views:

237

answers:

1

I had the following situation:

  • main application has app.xaml, which sets the style for TextBox controls
  • a custom control is implemented in a separate DLL, and uses several TextBox controls

The main application's TextBox style is applied to the custom control's TextBox controls. Cool!

My problem comes in because I need to use a class derived from TextBox in the custom control. Now the main app's TextBox style is no longer applied. Can the custom control DLL have something like "app.xaml" where I can set the style for all my derived TextBox controls? Or can the main application somehow set the style for all TextBox-derived classes?

Thanks!

A: 

You can set the BasedOn property of the custom TextBox style to the base style. Should automatically derive from whichever base style it inherits, in this case your application-level style.

<Style x:Key="CustomControlStyle" TargetType="{x:Type local:CustomControl}" BasedOn="{x:Type TextBox}">
Jeff Wain