Question

I am using the following markup in 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:

Value 'RadioButton.Checked' cannot be assigned to property 'RoutedEvent'. Invalid event name.

Any idea why, and how can I fix this?

Was it helpful?

Solution

RadioButton is a ToggleButton. The designer does support the attached ToggleButton properties, but not the RadioButton ones (except in a RadioButton tag of course).

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

So in your case, use <EventTrigger RoutedEvent="ToggleButton.Checked ..." ;-)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow