How can I check in Xaml if an ObservableCollection
bound to an ItemsSource
of a MenuItem
is empty or not? Based on that I would like to enable or disable the MenuItem
.
Whats desired:
<MenuItem
ItemsSource="{Binding loadables}"
Tag="{Binding load}">
<MenuItem.Triggers>
<Trigger Property="HasItems" Value="False">
<Setter Property="IsEnabled" Value="False"/>
</Trigger>
</MenuItem.Triggers>
</MenuItem>
You can trigger something when loadables.Count
is 0
<MenuItem ItemsSource="{Binding loadables}" Tag="{Binding load}">
<MenuItem.Style>
<Style TargetType="{x:Type MenuItem}">
<Style.Triggers>
<DataTrigger Binding="{Binding loadables.Count}" Value="0">
<Setter Property="IsEnabled" Value="False"/>
</DataTrigger>
</Style.Triggers>
</Style>
</MenuItem.Style>
</MenuItem>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With