I have a DataGrid
which bound a List<T>
, this is the structure:
<DataGrid x:Name="myDataGrid"
ItemSource="{Binding myList}" />
I want enable a button only if there is items myDataGrid
, actually I'm able to enable the button only if the user have selected an item in this way:
<Button>
<Button.Style>
<Style TargetType="Button">
<Setter Property="IsEnabled" Value="True" />
<Setter Property="Opacity" Value="1" />
<Style.Triggers>
<DataTrigger Binding="{Binding Path=SelectedItem, ElementName=myDataGrid}" Value="{x:Null}">
<Setter Property="IsEnabled" Value="False" />
<Setter Property="Opacity" Value=".5" />
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
how can I do that?