xml - WPF, display attribute value in TreeView instead of node name -
If I have the following data template for TreeView
, then what do I need to change each Returns the value of the name
attribute on each XML node instead of the TreeViewItem
node name?
& lt; HierarchicalDataTemplate x: key = "NodeTemplate" & gt; & Lt; TextBox x: name = "TB" /> & Lt; HierarchicalDataTemplate.ItemsSource & gt; & Lt; Binding XPath = "child :: node ()" /> & Lt; /HierarchicalDataTemplate.ItemsSource> & Lt; HierarchicalDataTemplate.Triggers & gt; & Lt; Datatrigger binding = "{binding path = node type}" value = "text" & gt; & Lt; Setter target name = "TB" property = "text" value = "{binding path = value}" /> & Lt; / DataTrigger & gt; & Lt; Data Trigger Binding = "{Binding Path = Node Type}" Value = "Element" & gt; & Lt; Setter target name = "TB" property = "text" value = "{binding path = name}" /> & Lt; / DataTrigger & gt; & Lt; /HierarchicalDataTemplate.Triggers> & Lt; / HierarchicalDataTemplate & gt;
Change your binding with:
& Lt; Setter TargetName = "TB" property = "text" value = "{binding path = attributes [name]. Value}" />
The answer was found.
Comments
Post a Comment