zoukankan      html  css  js  c++  java
  • Dynamic View of DataGrid

    XAML:

    <Window x:Class="PropertyGridDemo.Test"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:pg="clr-namespace:Syncfusion.Windows.PropertyGrid;assembly=Syncfusion.PropertyGrid.Wpf"        
             xmlns:dg="clr-namespace:Syncfusion.Windows.Controls.Grid;assembly=Syncfusion.Grid.Wpf" 
            Title="Test" Height="500" Width="800">
        <Grid>
            <Grid.RowDefinitions >
                <RowDefinition ></RowDefinition>
                <RowDefinition ></RowDefinition>
                <RowDefinition ></RowDefinition>
            </Grid.RowDefinitions>
            <pg:PropertyGrid 
                Grid.Row="2" 
                Name="pg" 
                PropertyExpandMode="NestedMode"
                EnableGrouping="True" 
                SelectedObject="{Binding ElementName=lb,Path=SelectedItem,Mode=TwoWay}" ></pg:PropertyGrid>
            <ListBox Name="lb" Grid.Row="1" ItemsSource="{Binding ElementName=dg,Path=VisibleColumns,Mode=TwoWay}" DisplayMemberPath="MappingName"></ListBox>
            <dg:GridDataControl
                Name="dg" 
                AutoPopulateColumns="True" 
                ItemsSourceChanged="dg_ItemsSourceChanged" 
                Grid.Row="0"></dg:GridDataControl>
        </Grid>
    </Window>

    Backend code:

     public partial class Test : Window
        {
            public Test()
            {
                InitializeComponent();
                this.dg.ItemsSource = Data.Gets();
    
                      
            }
    }

     public class Data
        {
            public int ID { get; set; }
            public string Name { get; set; }
            public bool IsMale { get; set; }
    
            public static IEnumerable Gets()
            {
                List<Data> data = new List<Data>();
                for (int i = 0; i < 100; i++)
                    data.Add(new Data { ID = i, Name = "Name" + i, IsMale = i % 3 == 2 });
                return data;
            }
        }
    

      

    Screenshot:

  • 相关阅读:
    HDU
    HDU
    [JSOI2009]计数问题 二维树状数组BZOJ 1452
    THU 上机 最小邮票数 暴力枚举
    SJTU 机试 最小面积子矩阵 压缩+双指针
    SJTU 机试 数学
    Preprefix sum BZOJ 3155 树状数组
    [HNOI2004]树的计数 BZOJ 1211 prufer序列
    HDU 5009
    上下界网络流模型常见解法
  • 原文地址:https://www.cnblogs.com/mjgb/p/2772235.html
Copyright © 2011-2022 走看看