Property Grid - Any ways to show a control inside a category?

Grids for WPF Forum

Posted 4 months ago by eric
Version: 18.1.0674
Avatar

Hi,

in our previous application we have built our own property grid to show and edit an object.

For some of those objects we want to display a datagrid with add/remove button to see all the data at once.

Here is a picture of what i would like to acheive: https://ibb.co/QbqNrM6

 

I would like to use the property grid to acheive this since most of the time i want to display <Name/Values> properties but would like in some cases to inject a control instead of a given property.

 

Is that possible? I saw the example using the Category Editor which have kind of the desired behavior but it  requires to have a property with a given type inside the category while what i want is to inject a control not bound to a property anywhere in a category.

Comments (4)

Posted 4 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Eric,

Correct, a category editor might be the best way to handle this since it would let you span an editor across the name/value cells.  I believe you could probably create a new CategoryEditorModel and initialize its EditorTemplate property with the DataTemplate to use.  You'd want to make a custom data factory that inherits TypeDescriptorFactory and override the GetDataModels method to inject your custom CategoryEditorModel instead as a result when appropriate per the request that comes in, which tells you the parent data model.


Actipro Software Support

Posted 4 months ago by eric
Avatar

Hi thank you for your comment.

Although by using this approach, i need to display at least one property with the given Category name in order to have my CategoryEditor displayed.

In my case, the datagrid would need to be displayed alone and would have nothing else displayed in the category other than this datagrid.

So i understand this is not possible? If this is the case, would it be possible to implement this?

Posted 4 months ago by eric
Avatar

So i managed to make it "work"

 

Here is what i did:

<grids:PropertyGrid SortComparer="{x:Null}" >
<grids:PropertyGrid.CategoryEditors>

<grids:CategoryEditor Category="System Busses" DisplayName="System Busses" >
<grids:CategoryEditor.Properties>
<grids:CategoryEditorProperty PropertyType="system:String" />
</grids:CategoryEditor.Properties>
<grids:CategoryEditor.EditorTemplate>
<DataTemplate>
<Button Content="TEST BUTTON"/>
</DataTemplate>
</grids:CategoryEditor.EditorTemplate>
</grids:CategoryEditor>

</grids:PropertyGrid.CategoryEditors>

<grids:PropertyModel Category="System Busses" ValueType="system:String" DisplayName="DUMMY VALUE" Value="DUMMY VALUE"/>

</grids:PropertyGrid>

 

Although im at a prototyping phase so im not sure if it will actually be working as im expecting before a few weeks/months.

Posted 4 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

What I was suggesting before is skipping over the whole normal category editor mechanism where it consumes a property and instead programmatically injecting a category editor via the data factory.

But if what you pasted above works for your needs, then great!


Actipro Software Support

The latest build of this product (v2018.1 build 0675) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.