What's the replacement of PropertyGridCategoryItem (pre 2017.1)?

Grids for WPF Forum

Posted 7 years ago by Markus Springweiler
Version: 17.1.0651
Avatar

I currently have a static tree (using native WPF baml translation) created this way:

 

<pg:PropertyGrid.Items>
	<pg:PropertyGridCategoryItem x:Uid="Meta.File" DisplayName="File" Description="Basic metadata of the filesystem object">
		<pg:PropertyGridPropertyItem x:Uid="Meta.File.Name" DisplayName="Name" Value="{Binding Name}" />
		<pg:PropertyGridPropertyItem x:Uid="Meta.File.Folder" DisplayName="Folder" Value="{Binding Path}" />
		<pg:PropertyGridPropertyItem x:Uid="Meta.File.Size" DisplayName="Size" ValueType="{x:Type sys:Int64}" Value="{Binding Placeholder.Size}" />
		<!-- ... -->
	</pg:PropertyGridCategoryItem>

	<pg:PropertyGridCategoryItem x:Uid="Meta.Img" DisplayName="Image" Description="Image details of the 'selected' frame"
			DataContext="{Binding ImageInfo}" d:DataContext="{d:DesignInstance local:ImageDetails}">

		<pg:PropertyGridPropertyItem x:Uid="Meta.Img.Basic.Frame" DisplayName="internal Frame/Scene #" Value="{Binding Key}" />

		<pg:PropertyGridCategoryItem x:Uid="Meta.Img.Basic" DisplayName="Basic" Description="Basic image details (present for every image)">
			<pg:PropertyGridPropertyItem x:Uid="Meta.Img.Basic.Width" DisplayName="Width" Value="{Binding Width}" />
			<pg:PropertyGridPropertyItem x:Uid="Meta.Img.Basic.Height" DisplayName="Height" Value="{Binding Height}" />
			<!-- ... -->
		</pg:PropertyGridCategoryItem>

		<!-- ... -->
	</pg:PropertyGridCategoryItem>

	<!-- ... -->
</pg:PropertyGrid.Items>

 

The entire documentation does not contain the word "PropertyGridCategoryItem". The migration topic mentions to replace PropertyGridPropertyItem with PropertyModel, but I had no luck in building a tree this way (just get Exception about adding to System.Windows.Controls.ItemCollection because ItemsSource is used (not by me)):

<pg:PropertyGrid.Items>
<pg:PropertyModel x:Uid="Meta.File" DisplayName="File" Description="Basic metadata of the filesystem object">
<pg:PropertyModel.Children>
<pg:PropertyModel x:Uid="Meta.File.Name" DisplayName="Name" Value="{Binding NormalizedName, Mode=OneWay}" />

Comments (4)

Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Markus,

Sorry, it looks like we missed documenting that particular class.  We are adding:

PropertyGridCategoryItem (a class you could use to directly define a category in XAML) is removed.  Instead, add PropertyModel instances to the PropertyGrid.Properties collection and assign the proper category name to each PropertyModel.  They will be automatically categorized by the data factory.


Actipro Software Support

Posted 7 years ago by Markus Springweiler
Avatar

Thank you. But I'm still unsure how to define a multi-level-hierarchy that way.

Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Markus,

You could possibly use the nested categories feature (see the "Categorization and Sorting" topic) where you specify category hierarchy in a single category name string for each property.  Such as "Image\Basic" for your example when this feature is enabled.

But if you need anything more complicated than that, then you'd probably want to make a custom data factory and supply the property models that way.  With custom data factories, you have complete control over which data models are passed back.


Actipro Software Support

Posted 7 years ago by Markus Springweiler
Avatar

My main concern against custom data factories or custom viewmodels using ComponentModel Attributes (where localization becomes an anti-pattern for WPF [1] BTW) is - and none of the samples of your sample app target this - is that I already have very bad experience with controls which rebuild (or at least update a significant amount of) their visual tree on change of DataContext:

When I bind a PropertyGrid to the current item of a ListBox (I spotted no sample for this scenario) the user must be able to use the up/down cursors inside the ListBox to scroll fast through the collection without stuttering or even delays which are longer than the keyboard repeat rate.

I have to admit I did not have time for testing yet, but I definitely want to get rid of the Legacy assembly because it blocks me from using the new TreeListView which looks very promising.

[1] Assemblies which already use WPF baml localization by the use of [assembly: NeutralResourcesLanguage("en", UltimateResourceFallbackLocation.Satellite)] cannot add/use .resx-files; they just get ignored or lost on building/linking.

The latest build of this product (v24.1.3) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.