小编VRa*_*age的帖子

Xceed WPF propertyGrid显示扩展集合的项目

如何ObservableCollection<>在Xceed WPF PropertyGrid中显示一个自定义对象,其中每个List Item都可以展开以显示自定义对象属性.(即:

---- ----- PropertyGrid的

CoreClass

  • (+/-)ObservableCollection <CustomClass>

    • (+/-)CustomClass.Object1

      • Property1:价值

      • Property2:价值

      • ...

      • PropertyN:价值

    • (+/-)CustomClass.Object2

      • Property1:价值

      • Property2:价值

      • ...

      • PropertyN:价值

如果我使用[ExpandableObject]ObservableCollection<>只显示计数属性.

编辑:(添加代码)

MainWindow.xaml:

<Window x:Class="PropGridExample.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:PropGridExample"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <xctk:PropertyGrid x:Name="PropertyGrid" SelectedObject="{Binding BindingItem}"></xctk:PropertyGrid>
    </Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)

MainWindow.xaml.cs

public partial class MainWindow : Window
{
    public MainWindow()
    {
        MainWindowViewModel mwvm = new MainWindowViewModel();
        this.DataContext = mwvm;
        InitializeComponent();
    }
}
Run Code Online (Sandbox Code Playgroud)

MainWindowViewModel.cs

public class MainWindowViewModel
{
    public Item BindingItem { …
Run Code Online (Sandbox Code Playgroud)

c# wpf propertygrid

11
推荐指数
2
解决办法
3933
查看次数

标签 统计

c# ×1

propertygrid ×1

wpf ×1