Reputation:
I want to enable/disable a button depending on the count of items within 2 ListView controls.
Both ListViews must have at least 1 item (each) before the button control is being enabled.
So far, all I found was a way for one ListView without triggers:
// ToDo: ListViewTwo must be included
<Button IsEnabled="{Binding ElementName=ListViewOne, Path=Items.Count}" />
Is there any way to consider ListViewToo, too?
Upvotes: 0
Views: 733
Reputation: 169420
You should be able to use a Style
with two DataTrigger
s:
<Button>
<Button.Style>
<Style TargetType="Button">
<Style.Triggers>
<DataTrigger Binding="{Binding Items.Count, ElementName=listViewOne}" Value="0">
<Setter Property="IsEnabled" Value="False" />
</DataTrigger>
<DataTrigger Binding="{Binding Items.Count, ElementName=listViewTwo}" Value="0">
<Setter Property="IsEnabled" Value="False" />
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
Upvotes: 1