简体   繁体   English

Xceed.Wpf.Toolkit.PropertyGrid显示属性的子集

[英]Xceed.Wpf.Toolkit.PropertyGrid show subset of properties

I am using a propertygrid of an extension for wpf (Extended WPF Toolkit Community Edition), and in my application (runtime) as I select an item (the application is like an interface designer), like a Label (System.Windows.Controls.Label) it shows me all its properties. 我正在使用wpf扩展的属性网格(扩展的WPF Toolkit社区版),并在我的应用程序(运行时)中选择一个项目(该应用程序像界面设计器),例如Label(System.Windows.Controls)。标签),它显示了我的所有属性。 I want to show a subset of properties, like font size and color, for example. 我想显示属性的子集,例如字体大小和颜色。 Any ideas? 有任何想法吗?

By default the propertyGrid will autogenerate all the properties for a given object. 默认情况下,propertyGrid将自动生成给定对象的所有属性。 You can override this behavior by setting the AutoGenerateProperties property to False, and then provide a collection of PropertyDefinitions of the properties you would like to show. 您可以通过将AutoGenerateProperties属性设置为False来覆盖此行为,然后提供要显示的属性的PropertyDefinitions的集合。

<xctk:PropertyGrid x:Name="_propertyGrid" Width="450" Margin="10"
  AutoGenerateProperties="False">
  <!-- Only the following properties will be displayed in the PropertyGrid-->
      <xctk:PropertyGrid.PropertyDefinitions>
        <xctk:PropertyDefinition Name="FontSize" />
        <xctk:PropertyDefinition Name="FontFamily" />
        <xctk:PropertyDefinition Name="Foreground" />            
      </xctk:PropertyGrid.PropertyDefinitions>
</xctk:PropertyGrid>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM