zoukankan      html  css  js  c++  java
  • wpf treeview中的两个事件

    使用模板HierarchicalDataTemplate

    <HierarchicalDataTemplate x:Key="BookMarkTemplate" >
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding Child.MarkName,Mode=TwoWay}"></TextBlock>
                </StackPanel>
            </HierarchicalDataTemplate>
            <HierarchicalDataTemplate x:Key="ChapterTemplate" ItemTemplate="{StaticResource BookMarkTemplate}" ItemsSource="{Binding InlineList,Mode=TwoWay}" >
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding Name}"></TextBlock>
                </StackPanel>
            </HierarchicalDataTemplate>

    从父节点删除选中项

      <TreeView  x:Name="treeview"  TreeViewItem.Selected="treeView1_Selected" ItemTemplate="{StaticResource ChapterTemplate}">

    private void treeView1_Selected(object sender, RoutedEventArgs e)
            {
                if ((e.OriginalSource as TreeViewItem).Header.GetType()==typeof(InlineUIContainer))
                {
                    mark = ((e.OriginalSource as TreeViewItem).Header as InlineUIContainer);
                    BookMarkRun run = mark.Child as BookMarkRun;
                    txtSelectionContent.Text = run.MarkName;
                    DependencyObject parent = VisualTreeHelper.GetParent((e.OriginalSource as TreeViewItem));
                    while (!(parent is TreeViewItem))
                        parent = VisualTreeHelper.GetParent(parent);
                    TreeViewItem item = (TreeViewItem)parent;
                    volumeModel = (item.Header as VolumeModel);
                    btnAdd.Content = "修改";
                    btnDel.IsEnabled = true;
                    btnAdd.IsEnabled = true;
                }
         }
  • 相关阅读:
    mysql 表分区
    mysql 存储过程和函数
    mysql 主从复制
    nginx 生产中配置记录
    harbor资源管理垃圾回收
    harbor部署
    docker使用nfs 做跨主机存储
    基于Gluster分布式实现docker存储卷
    docker 部署elasticsearch集群
    记一次iptables配置(REJECT --reject-with icmp-host-prohibited)
  • 原文地址:https://www.cnblogs.com/lzhp/p/3275136.html
Copyright © 2011-2022 走看看