Click here to Skip to main content
15,888,286 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a button and a datagrid. I'm binding list to DataGrid and also created static DataGrid Column of RadioButton. If I select any of the RadioButton from the DataGrid I want my button to get enabled. So below is what I have tried but still unable to fix the issue.
XML
<Button HorizontalAlignment="Right" Margin="5,0,0,0"  Height="23" Content="Enable/Disable">
    <Button.Style>
       <Style TargetType="Button">
           <Setter Property="IsEnabled" Value="False" />
           <Style.Triggers>
               <DataTrigger Binding="{Binding ElementName=SelectItems, Path=IsChecked}" Value="True">
                   <Setter Property="IsEnabled" Value="True" />
               </DataTrigger>
           </Style.Triggers>
       </Style>
    </Button.Style>
</Button>


XML
<DataGrid ScrollViewer.HorizontalScrollBarVisibility="Auto" BorderBrush="Black" Grid.Row="2" VerticalAlignment="Stretch" ItemsSource="{Binding ListOfItems}" CanUserAddRows="False" IsReadOnly="True" CanUserDeleteRows="False" CanUserResizeColumns="False" HorizontalGridLinesBrush="Black" VerticalGridLinesBrush="Black">
    <DataGrid.Resources>
        <Style TargetType="DataGridColumnHeader">
            <Setter Property="Width" Value="95" />
        </Style>
    </DataGrid.Resources>
    <DataGrid.Columns>
        <DataGridTemplateColumn Width="25">
            <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                    <RadioButton x:Name="SelectItems" HorizontalAlignment="Center" GroupName="Trail"/>
                </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
        </DataGridTemplateColumn>
    </DataGrid.Columns>
</DataGrid>




I'm very new to ElementBinding. Not sure what I'm missing.

Thank You.

What I have tried:

I also tried to set IsChecked to a bool property at my ViewModel, but IsChecked property was not setting the value to the property.
Posted
Updated 12-Jun-16 1:26am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900