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

TextBox in DataGridTemplateColumn CellTemplate with TreeView wpf mvvm

$
0
0

I have a data grid which has three columns and one of the column i have looks like below:

<DataGridTemplateColumn Header="Field" Width="*"><DataGridTemplateColumn.CellEditingTemplate><DataTemplate><converters:ExtendedTreeView
                                                ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor,
                                                            AncestorType={x:Type UserControl}}, Path=DataContext.FieldMapData,Mode=TwoWay}"
                                                Width="200"  x:Name="myFieldTree"
                                                SelectedItem_ = "{Binding RelativeSource={RelativeSource FindAncestor,
                                                            AncestorType={x:Type UserControl}}, Path=DataContext.SelectedTestStep.FieldNodeItem,
                                                           UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"><TreeView.Resources><DataTemplate x:Key="NormalTemplate"><StackPanel Orientation="Horizontal"><Image Width="16" Height="16" Margin="0,0,3,0" x:Name="iconTreeItem" /><TextBlock Text="{Binding NodeName,Mode=TwoWay}" /></StackPanel><DataTemplate.Triggers><DataTrigger Binding="{Binding Path=IsSelected,RelativeSource={RelativeSource AncestorType=TreeViewItem},
                                                        Converter={StaticResource isNullConverter}}" Value="False"><Setter TargetName="iconTreeItem" Property="Source"><Setter.Value><Binding  Converter="{StaticResource iconConverter}"><Binding.FallbackValue><ImageSource>
                                                                            ../Images/Unknown.png</ImageSource></Binding.FallbackValue></Binding></Setter.Value></Setter></DataTrigger></DataTemplate.Triggers></DataTemplate></TreeView.Resources><TreeView.ItemContainerStyle><Style TargetType="{x:Type TreeViewItem}"><Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" /><Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" /><Setter Property="FontWeight" Value="Normal" /><Style.Triggers><Trigger Property="IsSelected" Value="True"><Setter Property="FontWeight" Value="Bold" /></Trigger></Style.Triggers></Style></TreeView.ItemContainerStyle><TreeView.ItemTemplate><HierarchicalDataTemplate ItemsSource="{Binding Children}" DataType="{x:Type interfaces:INode}"><ContentPresenter Content="{Binding}"><ContentPresenter.Style><Style TargetType="{x:Type ContentPresenter}"><Setter Property="ContentTemplate" Value="{StaticResource   NormalTemplate}"/></Style></ContentPresenter.Style></ContentPresenter></HierarchicalDataTemplate></TreeView.ItemTemplate></converters:ExtendedTreeView></DataTemplate></DataGridTemplateColumn.CellEditingTemplate><DataGridTemplateColumn.CellTemplate><DataTemplate><TextBlock Text="{Binding FieldNodeItem.NodeName,Mode=TwoWay}"  ></TextBlock></DataTemplate></DataGridTemplateColumn.CellTemplate></DataGridTemplateColumn>

When user doesn't find the value he is looking for in the treeviewitem in the column , i want him to enter value manually. For thiis i tried to make the textblock as textbox but it never shows the treeview. Can we still get treeview displayed here ? If i modify the above celltemplate from textblock to textbox only but not the treeview.

<DataGridTemplateColumn.CellTemplate><DataTemplate><TextBox Text="{Binding FieldNodeItem.NodeName,Mode=TwoWay}"  ></TextBox></DataTemplate></DataGridTemplateColumn.CellTemplate>



Krrishna




Viewing all articles
Browse latest Browse all 18858

Trending Articles



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