扩展的 WPF 工具包:在 PropertyGrid 中显示项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12376991/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 05:18:52  来源:igfitidea点击:

The Extended WPF Toolkit: Show items in PropertyGrid

wpfdata-bindingmvvm

提问by Mohammed Thabet

I would like to show some items in a control like property control in visual studio when i searched on the internet I found the most powerful tool is : PropertyGridbut when i try follow the instruction the control failed to show values at my side . let me show snippet of code :

当我在互联网上搜索时,我想在 Visual Studio 中的属性控件等控件中显示一些项目,我发现最强大的工具是:PropertyGrid但是当我尝试按照说明操作时,控件未能在我身边显示值。让我展示代码片段:

<xctk:PropertyGrid 
    SelectedObject="{Binding Markets}"  AutoGenerateProperties="False" HorizontalAlignment="Left" Margin="155,10,0,0" VerticalAlignment="Top" Height="242" Width="319">
    <xctk:PropertyGrid.PropertyDefinitions>
            <xctk:PropertyDefinition Name="Name" />

            </xctk:PropertyGrid.PropertyDefinitions>
</xctk:PropertyGrid>

and Markets are List of Market and Market class contain property called Name

和市场是市场列表,市场类包含名为名称的属性

回答by W3t Tr3y

As has been mentioned elsewhere (Using Xceed PropertyGrid) the trick is to set the SelectedObject. It confused me at first too as many of the example do not include that property and searching didn't turn up solutions like the one linked above.

正如其他地方提到的(使用 Xceed PropertyGrid),诀窍是设置 SelectedObject。起初它也让我感到困惑,因为许多示例不包含该属性,并且搜索没有找到像上面链接的那样的解决方案。