Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在WPF中构建类似VS的propertypanel?_C#_Wpf_Visual Studio - Fatal编程技术网

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>