I am using the following markup in WPF:
我在WPF中使用以下标记:
<StackPanel.Triggers>
<EventTrigger RoutedEvent="RadioButton.Checked" SourceName="xmlRadioButton">
<EventTrigger.Actions>
<BeginStoryboard Storyboard="{StaticResource ShowXmlPanel}"/>
</EventTrigger.Actions>
</EventTrigger>
<EventTrigger RoutedEvent="RadioButton.Checked" SourceName="adiRadioButton">
<EventTrigger.Actions>
<BeginStoryboard Storyboard="{StaticResource ShowAdiPanel}"/>
</EventTrigger.Actions>
</EventTrigger>
</StackPanel.Triggers>
Though this works fine when I run the code, I get the following error in the designer window of VS 2008:
虽然这在我运行代码时工作正常,但我在VS 2008的设计器窗口中收到以下错误:
Value 'RadioButton.Checked' cannot be assigned to property 'RoutedEvent'. Invalid event name.
值'RadioButton.Checked'无法分配给属性'RoutedEvent'。无效的活动名称。
Any idea why, and how can I fix this?
知道为什么,我该如何解决这个问题?
1 个解决方案
#1
3
RadioButton
is a ToggleButton
. The designer does support the attached ToggleButton
properties, but not the RadioButton
ones (except in a RadioButton
tag of course).
RadioButton是一个ToggleButton。设计器确实支持附加的ToggleButton属性,但不支持RadioButton属性(当然,除了RadioButton标记)。
You need to use the class name that defines the property/event for the designer to accept it (thought there is no difference at runtime, since RadioButton
IS a ToggleButton
as I said, but the designer is not a real compiler).
你需要使用为设计者定义属性/事件的类名来接受它(认为在运行时没有区别,因为RadioButton就像我说的那样是一个ToggleButton,但设计师并不是真正的编译器)。
So in your case, use <EventTrigger RoutedEvent="ToggleButton.Checked ..."
;-)
所以在你的情况下,使用
#1
3
RadioButton
is a ToggleButton
. The designer does support the attached ToggleButton
properties, but not the RadioButton
ones (except in a RadioButton
tag of course).
RadioButton是一个ToggleButton。设计器确实支持附加的ToggleButton属性,但不支持RadioButton属性(当然,除了RadioButton标记)。
You need to use the class name that defines the property/event for the designer to accept it (thought there is no difference at runtime, since RadioButton
IS a ToggleButton
as I said, but the designer is not a real compiler).
你需要使用为设计者定义属性/事件的类名来接受它(认为在运行时没有区别,因为RadioButton就像我说的那样是一个ToggleButton,但设计师并不是真正的编译器)。
So in your case, use <EventTrigger RoutedEvent="ToggleButton.Checked ..."
;-)
所以在你的情况下,使用