How to control CellEditingTemplate to show on demand?

Jun 24, 2009 at 8:21 AM

Hi all,

I define a CellEditingTemplate for my DataGridTemplateColumn. Current problem is the cell should be editable on demand. It means it will show or not show the CellEditingTemplate by my condition. For example by IsCSEnabled property.

So is there any good way to control it?
It's my code below.

                <dg:DataGridTemplateColumn Header="Coordinate System" Width="70">
                    <dg:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Path=CS, Converter={StaticResource CSToDisplayConverter}}"
                                       Visibility="{Binding Path=IsFileInGroup, Converter={StaticResource BoolTrueToHidden}}"/>
                        </DataTemplate>
                    </dg:DataGridTemplateColumn.CellTemplate>
                    <dg:DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <DockPanel HorizontalAlignment="Stretch" Visibility="{Binding Path=IsFileInGroup, Converter={StaticResource BoolTrueToHidden}}">
                                <Button Content="..." Width="30" DockPanel.Dock="Right" Click="btnCSPicker_Click"/>
                                <TextBox Text="{Binding Path=CS, Converter={StaticResource CSToDisplayConverter}}" HorizontalContentAlignment="Stretch"/>
                            </DockPanel>
                        </DataTemplate>
                    </dg:DataGridTemplateColumn.CellEditingTemplate>
                </dg:DataGridTemplateColumn>

Thanks very much
Dan