Dabblernl
Dabblernl

Reputation: 16121

How can I have my inherited TextBox use the style of the Button Type

I am using a custom TextBox that inherits from TextBox:

Public Class MyTextBox: Inherits TextBox
    ...
End Class

I want this class to use the Style that is defined in the classic.xaml ResourceDictionary. I tried this:

 <Style x:Key="{x:Type uc:MyTextBox}" BasedOn="{StaticResource {x:Type TextBox}}"/>


    <Style x:Key="{x:Type TextBox}"
       BasedOn="{StaticResource {x:Type TextBoxBase}}"
       TargetType="{x:Type TextBox}">
    <!-- predefined style in classic.xaml-->
    </Style>

But I am greeted with an error message stating that the style can only be based on a type of IFrameworkInputElement.

This should be trivial, shouldn´t it?

Upvotes: 3

Views: 616

Answers (1)

Adi Lester
Adi Lester

Reputation: 25211

You need to add TargetType="{x:Type uc:MyTextBox}" to your style.

Upvotes: 2

Related Questions