Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

New Post: Setting CategoryOrder via PropertyGrid PropertyDefinitions

$
0
0
Hi,

Try setting attributes instead. You can set "CategoryAttribute" over each property to specify its Category and "CategoryOrderAttribute" over your object class (to specify the Categories order) which is your PropertyGrid's SelectedObject. Ex :
<Grid>
    <xctk:PropertyGrid SelectedObject="{Binding}"
                       AutoGenerateProperties="False">
      <xctk:PropertyGrid.PropertyDefinitions>
        <xctk:PropertyDefinition Name="Test3"
                                 Category="C3"/>
        <xctk:PropertyDefinition Name="Test2"
                                 Category="C2" />
        <xctk:PropertyDefinition Name="Test1"
                                 Category="C1" />
      </xctk:PropertyGrid.PropertyDefinitions>
    </xctk:PropertyGrid>
  </Grid>
 public partial class MainWindow : Window
  {
    public MainWindow()
    {
      InitializeComponent();
      this.DataContext = new MyData();
    }
  }

  [CategoryOrder( "C1", 3) ]
  [CategoryOrder( "C2", 2 )]
  [CategoryOrder( "C3", 1 )]
  public class MyData
  {
   // [Category("C1")]   //Can be done as an attribute or in XAML
    public int Test1
    {
      get;
      set;
    }
   // [Category( "C2" )]   //Can be done as an attribute or in XAML
    public int Test2
    {
      get;
      set;
    }
   // [Category( "C3" )]   //Can be done as an attribute or in XAML
    public int Test3
    {
      get;
      set;
    }
    public int Test4
    {
      get;
      set;
    }
  }

Viewing all articles
Browse latest Browse all 4964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>