3
有没有办法在另一种风格中定义的样式中删除事件处理程序?删除xaml样式的事件处理程序?
这里是一个人为的例子:
<Style TargetType="{x:Type TextBox}" x:Key="DefaultTextBoxStyle">
<EventSetter Event="GotFocus" Handler="TextBox_GotFocus"/>
<EventSetter Event="LostFocus" Handler="TextBox_LostFocus"/>
<EventSetter Event="PreviewKeyUp" Handler="TextBox_PreviewKeyUp"/>
</Style>
<Style TargetType="{x:Type TextBox}" x:Key="InlineTextBox" BasedOn="{DynamicResource DefaultTextBoxStyle}">
<EventSetter Event="GotFocus" Handler="????"/> // set to nothing
<EventSetter Event="LostFocus" Handler="????"/> // set to nothing
<EventSetter Event="PreviewKeyUp" Handler="????"/> // set to nothing
</Style>
谢谢!
不会工作......它会像'this.GotFocus = null',这是不合法的。您只能通过+ =和 - = – 2009-08-06 14:21:49
访问事件阅读...原来是基础:D – user7116 2009-08-06 14:34:19
谢谢!看起来像现在最好的解决方案。 – djcouchycouch 2009-08-06 14:45:53