inherit style from default style RRS feed

  • Question

  • In my project there is a custom style for text box. It is defined as:

    <Style TargetType="TextBox"/>

    So it is applied to all text box child controls by default.

    I need to create another style that is based on default style. But how do I specify in the BasedOn attribute that my new style should use the default style?

    Friday, July 20, 2012 2:35 PM


  • I think you need to use x:Type to get this to work.

    <Style TargetType="{x:Type TextBox}">

    Then you can use 'based on' as follows:

    <Style x:Key="InheritedStyle" BasedOn="{StaticResource {x:Type TextBox}}" TargetType="{x:Type TextBox}">

    Hope that helps!

    Christine A. Piffat

    Friday, July 20, 2012 2:48 PM