本文介绍了我需要在treeview中显示xml数据,并使用mvvm.please帮助我在wpf中的节点值中显示可编辑模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的xml文件格式:

this my xml file format:

<props>
  <specific_criteria>NONE</specific_criteria>
  <specific_condition>NEW</specific_condition>
  <specific_disposition>
    <disposition>NONE</disposition>
  </specific_disposition>
  <specific_model>NONE</specific_model>
  <specific_velocity>NONE</specific_velocity>
  <specific_cons_model>NONE</specific_cons_model>
  <specific_program>
    <program>NONE</program>
  </specific_program>
  <specific_operation>NONE</specific_operation>
  <specific_oem>NONE</specific_oem>
  <specific_esn_status />
  <special_criteria />
  <same_disposition>N</same_disposition>
  <same_model>N</same_model>
  <same_sku>N</same_sku>
  <same_esn_status>N</same_esn_status>
  <same_cons_model>N</same_cons_model>
  <same_condition>N</same_condition>
  <same_velocity>N</same_velocity>
  <same_receipt>N</same_receipt>
  <same_oem>N</same_oem>
</props>



i需要在树视图中显示,还需要在节点值中显示可编辑模式在wpf中使用mvvm


i need to show in treeview and also editiable mode in node values in wpf using mvvm

推荐答案

<TreeView x:Name="MyTreeView">
           <TreeView.Resources>
               <DataTemplate x:Key="NormalTemplate">
                   <StackPanel Orientation="Horizontal">
                       <TextBlock Text="{Binding ID}" Margin="3"/>
                       <TextBlock Text="-" Margin="3"/>
                       <TextBlock Text="{Binding Name}" Margin="3"/>
                   </StackPanel>
               </DataTemplate>
               <DataTemplate x:Key="EditTemplate">
                   <TextBox Text="{Binding Name}"/>
               </DataTemplate>
           </TreeView.Resources>
           <TreeView.ItemTemplate>
               <HierarchicalDataTemplate
                            ItemsSource="{Binding Team}">
                   <ContentPresenter Content="{Binding}">
                       <ContentPresenter.Style>
                           <Style TargetType="{x:Type ContentPresenter}">
                               <Setter Property="ContentTemplate"
                                       Value="{StaticResource
                                               NormalTemplate}"/>
                               <Style.Triggers>
                                   <DataTrigger
                                        Binding="{Binding IsSelected,
                                        RelativeSource={RelativeSource
                                             FindAncestor,
                                        AncestorType={x:Type TreeViewItem}}}"
                                             Value="True">
                                       <Setter Property="ContentTemplate"
                                               Value="{StaticResource
                                                       EditTemplate}" />
                                   </DataTrigger>
                               </Style.Triggers>
                           </Style>
                       </ContentPresenter.Style>
                   </ContentPresenter>
               </HierarchicalDataTemplate>
           </TreeView.ItemTemplate>
       </TreeView>







让我知道这有帮助!!!

完整来源:



这篇关于我需要在treeview中显示xml数据,并使用mvvm.please帮助我在wpf中的节点值中显示可编辑模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 01:40