2012-02-01 29 views
3

的风格,我使用的是从文本框继承的自定义文本框:我怎么能有我的继承文本框使用按钮类型

Public Class MyTextBox: Inherits TextBox 
    ... 
End Class 

我想这个类为使用中的经典定义的样式。 xaml ResourceDictionary。我尝试这样做:

<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> 

但我有错误消息,指出风格只能基于一种IFrameworkInputElement的欢迎。

这应该是微不足道的,不是吗?

回答

2

你需要添加TargetType="{x:Type uc:MyTextBox}"到你的风格。