如何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)