'WPF XAML DataGrid - update the value of one column based on that of another

I have a DataGrid which features a CombBox column and an Item column. The drop down is a CollectionView with "START" and "NONE" in. If "START" is selected then a command is raised to allow the user to select an item which is assigned to a Button in the Item column (Which can be clicked to allow re-selection).

I'd like it so that if "NONE" is selected, this Button is removed - preferable if the underlying ViewModel is updated appropriately - and that the other column is greyed out and disabled. I can do the latter but I'm not sure how to do the former.

It's also not good enough that the button is just hidden - I need the underlying "Item" to no longer bassigned to it.

Here is what my XAML looks like:

<DataGrid.Columns>
    <DataGridComboBoxColumn Header="My Cmnd" Width="*"
    SelectedItemBinding="{Binding MY_COMMAND,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
    ItemsSource="{Binding Source={StaticResource MyCmndTypesCVS}}"  />
    <DataGridTemplateColumn Header="Item Name">
        <DataGridTemplateColumn.CellTemplate>
            <DataTemplate>
                <Button Content="{Binding MyName,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                        Command="{Binding Path=DataContext.SelectMyCommand,
                            RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
            </DataTemplate>
        </DataGridTemplateColumn.CellTemplate>
        <DataGridTemplateColumn.CellStyle>
            <Style TargetType="DataGridCell" >
                <Setter Property="IsEnabled" Value="True" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding MY_COMMAND}" Value="NONE">
                        <Setter Property="IsEnabled" Value="False" />
                        <Setter Property="Background" Value="Gray" />
                        <Setter Property="BorderBrush" Value="Gray" />                                                                
                    </DataTrigger>                                  
                </Style.Triggers>
            </Style>
        </DataGridTemplateColumn.CellStyle>
    </DataGridTemplateColumn>
<DataGrid.Columns>

Is there a way to get the DataTrigger to set an underlying ViewModel property to null?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source