سؤال

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?

هل كانت مفيدة؟

المحلول

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top