Hi,
I'm trying to change a Button's Click property/event when a DataTrigger is triggered but I'm not sure if this is the best method to do it. In fact, it won't even compile :)
What I have looks like this:
<Style TargetType="{x:Type Button}">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=ObjectTreeView, Path=SelectedItem.Replaceable}" Value="False">
<Setter Property="Content" Value="Add" />
<Setter Property="Button.Click" Value="AddObject_Click" />
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=ObjectTreeView, Path=SelectedItem.Replaceable}" Value="True">
<Setter Property="Content" Value="Replace" />
<Setter Property="Button.Click" Value="ReplaceObject_Click" />
</DataTrigger>
</Style.Triggers>
</Style>
Compiling gives me an error message saying "Cannot find the Style Property 'Click' on the type 'System.Windows.Controls.Button'"
Any suggestions? If this not possible, what alternatives are there?
Thanks!
Edit:
I thought I found the solution which was to use an EventSetter, but EventSetters aren't supported inside Triggers. What I thought would've worked was:
<EventSetter Event="Button.Click" Handlder="AddObject_Click" />
But like I said, this is supported at all.