zoukankan      html  css  js  c++  java
  • WPF TreeGrid Binding 简易实现方式

    在設計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="50" />
                            <ColumnDefinition Width="50" />
                            <ColumnDefinition Width="50" />
                            <ColumnDefinition Width="50" />
                            <ColumnDefinition Width="50" />
                        </Grid.ColumnDefinitions>
    
                        <TextBlock Text="{Binding Name}" />
                        <CheckBox  Grid.Column="1" 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="2" IsChecked="{Binding HasAdd,Mode=TwoWay}"          
                                  IsEnabled="{Binding Path=DataContext.IsInput,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}"
                                  >
                        </CheckBox>
                        <CheckBox Grid.Column="3" IsChecked="{Binding HasEdit,Mode=TwoWay}"          
                                  IsEnabled="{Binding Path=DataContext.IsInput,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}"
                                  >
                        </CheckBox>
                        <CheckBox Grid.Column="4" IsChecked="{Binding HasEditDetail,Mode=TwoWay}"          
                                  IsEnabled="{Binding Path=DataContext.IsInput,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}"
                                  >
                        </CheckBox>
                        <CheckBox Grid.Column="5" IsChecked="{Binding HasDelete,Mode=TwoWay}"          
                                  IsEnabled="{Binding Path=DataContext.IsInput,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}"
                                  >
                        </CheckBox>
                    </Grid>
                </HierarchicalDataTemplate>
  • 相关阅读:
    JAVA for(i = 0; i<a.length; i++) 解析
    3.2.2多维数组 3.3 排序
    3.2数组
    字符串和数组
    2.7.3与程序转移有关的跳转语句
    2.7.2 循环语句
    读书共享 Primer Plus C-part 4
    Linux 批量修改文件名
    关于/usr/local/lib/libz.a(zutil.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC解决办法
    做一个有深度的程序猿
  • 原文地址:https://www.cnblogs.com/CoreXin/p/4440703.html
Copyright © 2011-2022 走看看