WPF DataGrid Cell Properties

Nov 21, 2008 at 1:45 PM
Hi EveryOne,

I have a problem in enabling and Disabling the Controls in the WPF:DataGrid,
I am trying to Disable the TextBoxes in the DataGrid when the ComboBox in the same DataGrid gets the SelectedIndex as 0. The TextBoxes of the same row in which the ComboBox's SelectedIndex is 0 should be disabled.

For example, lets say there are 6 columns and 10 rows in a DataGrid,
ComboBox is in Column 3, rest are the TextBox Columns. If I set the ComboBox's SelectedIndex to 0(ZERO) of Row 3, then the TextBoxes in the Column 4 and 5 of the respective row(i.e., Row 3) has to be disabled,

Can Anybody please, help me out with this Issue????

Thank you in Advance.....
Nov 21, 2008 at 6:48 PM
Hi chetanarayan,

Something like the following should work....

        <DataGridComboBoxColumn SelectedItemBinding={Binding Path=Cake} />
                  <Style TargetType="{x:Type TextBox}">
                          <DataTrigger Binding="{Binding Path=Cake}" Value="Chocolate">
                              <Setter Property="IsEnabled" Value="False"></Setter>

Basically have a trigger for TextBox bound to the same property as is ComboBox and enable it appropriately.
Nov 24, 2008 at 5:05 AM
Thanks a lot Mr.Vamsee....