This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hello, I need to show/edit only a small subset of my object's properties. is it possible ? |
|
|
Certainly: use grid.BindingView.DefaultView.Filter and provide a predicate the selects only the properties you want to show/edit. See How Do I > Hide Properties and Help Topics > Sorting, Filtering and Grouping in the help file. Let us know if you need any further info! |
|
|
Forgot to mention: for example code, see the CustomizationWalkthrough sample. |
|
|
Could you provide a sample for how I could filter properties so that only properties with a particular attribute were visible and only properties with a different attribute were editable? I am currently evaluating the WPF Property Grid and this is key functionality that I need. Thanks |
|
|
To control visibility: either apply the [Browsable(false)] attribute to the properties you want to hide, or use a filter to look for your custom browsability attribute: grid.BindingView.DefaultView.Filter = delegate(object obj) To control editability: either apply [ReadOnly(true)] to the properties that are not editable, or if you already have an attribute for this, use a smart editor to map properties with that attribute to a read-only DataTemplate. See http://www.mindscape.co.nz/blog/index.php/2008/04/30/smart-editor-declarations-in-the-wpf-property-grid/ for the outline. You will need to change this sample as follows: 1. In the CanEdit override, return true for non-editable properties. To determine whether a property is editable or not, you can call node.Property.GetCustomAttributes() to check for the presence of your attribute. 2. When you map the editor to a DataTemplate, use a read-only DataTemplate e.g. <TextBlock Text="{Binding Value}" />. |
|