Reputation: 1767
I have a control that has a DataContext
being loaded and based on it I create a bunch of Button
s. I would like to have the Button
react on a change to the bound objects change
<Button ToolTip="{Binding Tip}"
ib:ButtonProperties.Image="{Binding EnabledSource}"
ib:ButtonDProperties.Image="{Binding DisabledSource}"
Content="{Binding Text}"
IsEnabled="{Binding DefaultEnabled}"
Tag="{Binding .}"
Click="ToolBarButtonButton_Click"
Style="{StaticResource ImageButton}">
</Button>
For simplification purposes, Lets say, I databind a collections of Custom objects which Have a Property called "IsPerfect" of type bool. The Object assigned to the button is set as the tag as well.
I would like to have the button reacting on the property "IsPerfect" that belongs to the databound object and then execute a eventhandler or enable/disable the button.
Upvotes: 0
Views: 208
Reputation: 551
You can use a style to fulfill your goal.
<Button>
<Button.Style>
<Style>
<DataTrigger Binding="{Binding IsPerfect}" Value="True">
<Setter Property="Button.IsEnabled" Value="True"></Setter>
</DataTrigger>
</Style>
<Button.Style>
</Button>
Upvotes: 0