C# 如何在WPF中构建类似VS的propertypanel?
我得到了一个C# 如何在WPF中构建类似VS的propertypanel?,c#,wpf,visual-studio,C#,Wpf,Visual Studio,我得到了一个TreeView,其中包含来自不同类的不同对象。现在我想构建一个propertypanel,它显示不同的内容,具体取决于在树视图中选择的对象/类。构建这样的面板的最佳方式是什么?不同的面板和折叠面板取决于选择(谁能让我更容易实现observer模式?)?或者其他方法?我会将属性面板(可能只是一个ContentControl)绑定到树视图中的SelectedItem: <ContentPanel Content="{Binding SelectedItem, ElementNam
TreeView
,其中包含来自不同类的不同对象。现在我想构建一个propertypanel,它显示不同的内容,具体取决于在树视图中选择的对象/类。构建这样的面板的最佳方式是什么?不同的面板和折叠面板取决于选择(谁能让我更容易实现observer模式?)?或者其他方法?我会将属性面板(可能只是一个ContentControl
)绑定到树视图中的SelectedItem
:
<ContentPanel Content="{Binding SelectedItem, ElementName=_treeView}"/>
显然,您的数据模板可以根据需要复杂到可以显示树视图中存在的各种类,您是说一个好的。。。我不知道那个。但我认为这会满足我的需求。+1,还有一个同名的Telerik组件,这更容易设置。
<DataTemplate DataType="{x:Type local:SomeClass}">
<Label>This is displayed for SomeClass</Label>
</DataTemplate>
<DataTemplate DataType="{x:Type local:SomeOtherClass}">
<Label>This is displayed for SomeOtherClass</Label>
</DataTemplate>