Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Enable/Disable DataGridTemplate Column in WPF DataGrid

$
0
0

In my datagrid I have  a DataGridTemplateColumn "TaxColumn"which should be enabled disabled accroding to the value of the field "POType".  I am using the DataTrigger as follows. But it is not working as I expects. The "TaxColumn" is always enabled.  Can anyone help me on this.?

 <DataGrid AutoGenerateColumns="False" Grid.Column="3" Grid.Row="1" Height="140" HorizontalAlignment="Left" Margin="2,0,0,40" Name="datPoDet" VerticalAlignment="Bottom" Width="784" Grid.ColumnSpan="9" IsReadOnly="False" TabIndex="16"  IsSynchronizedWithCurrentItem="True"   SelectionUnit="FullRow"  CanUserAddRows="True" >

            <DataGrid.Resources>
                <Style x:Key="TaxTextBoxStyle" TargetType="{x:Type my:TxtMasterData}">
                    <!-- Set Default -->
                    <Setter Property="IsEnabled" Value="false" />
                 
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding Path=POType}" Value="1">
                            <Setter Property="IsEnabled" Value="true" />
                            <Setter Property="Background" Value="White"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Path=POType}" Value="2">
                            <Setter Property="IsEnabled" Value="false" />
                          
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Path=POType}" Value="3">
                            <Setter Property="IsEnabled" Value="false" />
                           
                        </DataTrigger>
                       
                    </Style.Triggers>
                </Style>
            </DataGrid.Resources>

 <DataGridTemplateColumn    Width="150"    Header="Tax Combination" x:Name="dgcTaxComCode" SortMemberPath="TaxComCode" >

                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <my:TxtMasterData x:Name="txtTaxComCode" Text="{Binding Path=TaxComCode,  ValidatesOnExceptions=True,UpdateSourceTrigger=PropertyChanged}" cHelp="HelpTaxHed" SelectTable= "fTaxHed" KeyField="TaxComCode" LostFocus="txtTaxComCode_LostFocus" Style="{StaticResource TaxTextBoxStyle}"  />
                          
                           
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>

                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>

                            <my:TxtMasterData x:Name="txtTaxComCode" Text="{Binding Path=TaxComCode, UpdateSourceTrigger=PropertyChanged}" cHelp="HelpTaxHed" SelectTable= "fTaxHed" KeyField="TaxComCode" LostFocus="txtTaxComCode_LostFocus" Style="{StaticResource TaxTextBoxStyle}"/>
                          
                                       </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>

                </DataGridTemplateColumn>

            <DataGrid.Columns>


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>