在設計TreeView編輯狀況下,希望 TreeItemName 后续的编辑框 复选框 可以整齐排列。

参考微软提供的TREELISTVIEW,发现它是根据层级关系调整Margin 属性。

我这边按照同样的方式,实现WIDTH的宽度的递减,就可实现需要的效果。

<HierarchicalDataTemplate x:Key="TreeNodes" ItemsSource="{Binding Path=Childs,Mode=TwoWay}" >
<Grid DataContext="{Binding}" Width="{Binding Level,
Converter={StaticResource
LevelToWidthConverter}}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="" />
<ColumnDefinition Width="" />
<ColumnDefinition Width="" />
<ColumnDefinition Width="" />
<ColumnDefinition Width="" />
</Grid.ColumnDefinitions> <TextBlock Text="{Binding Name}" />
<CheckBox Grid.Column="" IsChecked="{Binding IsCheck}"
IsEnabled="{Binding Path=DataContext.IsInput,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}"
>
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<i:InvokeCommandAction Command="{Binding Path=DataContext.NodeChangeCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}"
CommandParameter="{Binding Id}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</CheckBox>
<CheckBox Grid.Column="" IsChecked="{Binding HasAdd,Mode=TwoWay}"
IsEnabled="{Binding Path=DataContext.IsInput,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}"
>
</CheckBox>
<CheckBox Grid.Column="" IsChecked="{Binding HasEdit,Mode=TwoWay}"
IsEnabled="{Binding Path=DataContext.IsInput,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}"
>
</CheckBox>
<CheckBox Grid.Column="" IsChecked="{Binding HasEditDetail,Mode=TwoWay}"
IsEnabled="{Binding Path=DataContext.IsInput,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}"
>
</CheckBox>
<CheckBox Grid.Column="" IsChecked="{Binding HasDelete,Mode=TwoWay}"
IsEnabled="{Binding Path=DataContext.IsInput,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}"
>
</CheckBox>
</Grid>
</HierarchicalDataTemplate>

WPF TreeGrid Binding 简易实现方式的更多相关文章

  1. WPF之Binding深入探讨

    原文:http://blog.csdn.net/fwj380891124/article/details/8107646 1,Data Binding在WPF中的地位 程序的本质是数据+算法.数据会在 ...

  2. WPF数据绑定Binding(二)

    WPF数据绑定Binding(二) 1.UI控件直接的数据绑定 UI对象间的绑定,也是最基本的形式,通常是将源对象Source的某个属性值绑定 (拷贝) 到目标对象Destination的某个属性上. ...

  3. WPF的Binding功能解析

    1,Data Binding在WPF中的地位 程序的本质是数据+算法.数据会在存储.逻辑和界面三层之间流通,所以站在数据的角度上来看,这三层都很重要.但算法在3层中的分布是不均匀的,对于一个3层结构的 ...

  4. WPF之Binding深入探讨--Darren

    1,Data Binding在WPF中的地位 程序的本质是数据+算法.数据会在存储.逻辑和界面三层之间流通,所以站在数据的角度上来看,这三层都很重要.但算法在3层中的分布是不均匀的,对于一个3层结构的 ...

  5. WPF之Binding【转】

    WPF之Binding[转] 看到WPF如此之炫,也想用用,可是一点也不会呀. 从需求谈起吧: 首先可能要做一个很炫的界面.见MaterialDesignInXAMLToolKit. 那,最主要的呢, ...

  6. WPF之Binding深入探讨 转载:http://blog.csdn.net/fwj380891124/article/details/8107646

    1,Data Binding在WPF中的地位 程序的本质是数据+算法.数据会在存储.逻辑和界面三层之间流通,所以站在数据的角度上来看,这三层都很重要.但算法在3层中的分布是不均匀的,对于一个3层结构的 ...

  7. 【转】WPF中Binding的技巧(一)

    WPF中Binding的技巧(一)   在WPF应用的开发过程中Binding是一个非常重要的部分. 在实际开发过程中Binding的不同种写法达到的效果相同但事实是存在很大区别的. 这里将实际中碰到 ...

  8. WPF之Binding的使用

    引出: 在WPF中Binding可以比作数据的桥梁,桥梁的两端分别是Binding的源(Source)和目标(Target).一般情况下,Binding源是逻辑层对象,Binding目标是UI层的控件 ...

  9. 深入浅出WPF之Binding的使用(一)

    在WPF中Binding可以比作数据的桥梁,桥梁的两端分别是Binding的源(Source)和目标(Target).一般情况下,Binding源是逻辑层对象,Binding目标是UI层的控件对象:这 ...

随机推荐

  1. Permission denied 解决办法

    Permission denied 解决的办法: $ sudo chmod -R 777 某一目录 其中-R 是指级联应用到目录里的所有子目录和文件777 是所有用户都拥有最高权限

  2. 【代码总结】Struts2 Action接受参数方式的对比

    一.属性方式 1.Action中:对应表单参数的setter.getter 2.页面中  :Form中元素name取值属性名 <s:property value="属性名" ...

  3. Docker - CentOS 7 安装

    1. 概述 安装 docker markdown 显示有点问题 代码块里的  后面应该跟一个换行, 但是没有跟 这样会导致部分命令直接执行没有反应 2. 环境 os CentOS7 用户 root 3 ...

  4. A. DZY Loves Chessboard

    DZY loves chessboard, and he enjoys playing with it. He has a chessboard of n rows and m columns. So ...

  5. nginx配置访问密码,输入用户名和密码才能访问

    1. 安装 htpasswd 工具 yum install httpd-tools -y 设置用户名和密码,并把用户名.密码保存到指定文件中: [sandu@bogon conf]$ sudo mkd ...

  6. 【C语言】找出1000以内可以被3整除的数

    分别用while,do-while,for语句实现 方法一:while #include<stdio.h> int main() { int m; m = ; ) { == ) print ...

  7. WKWebView 使用的坑

    WKWebView 简介: WKWebView 是苹果在 WWDC 2014 上推出的新一代 webView 组件,用以替代 UIKit 中笨重难用.内存泄漏的 UIWebView.WKWebView ...

  8. Bugku-CTF加密篇之贝斯家族(@iH<,{bdR2H;i6*Tm,Wx2izpx2!)

    贝斯家族 @iH<,{bdR2H;i6*Tm,Wx2izpx2!  

  9. tkinter+pickle+python的一个登录界面设计

    1.代码: #导出模块 import tkinter as tk from tkinter import messagebox import pickle #定义登录的窗口.标题.大小和位置 wind ...

  10. 【题解】Rusty String [CF827E]

    [题解]Rusty String [CF827E] 传送门:\(\text{Rusty String}\) \(\text{[CF827E]}\) [题目描述] 多组数据,每组数据给出一个由 \(V, ...