Styling a Property

Grids for WPF Forum

Posted 10 years ago by Eli Obadia
Version: 10.1.0523
From all the properties I have the are around 3 of then that are the ones than commonly the users will be changing I would like to make them easier to recognize, how can I make them look different, for instance how can I change the background of those 3 properties that are the "most important" for the end user?


Comments (2)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Eli,

You can use an implicit Style for the PropertyGridDataAccessorItem type, which includes one or more triggers. In the example below, we are looking for a specific property (i.e. Text), but you can customize this as needed.
    <Style TargetType="{x:Type propgrid:PropertyGridDataAccessorItem}">
                    <Condition Binding="{Binding DataAccessorType, RelativeSource={RelativeSource Self}}" Value="Property" />
                    <Condition Binding="{Binding ValueName, RelativeSource={RelativeSource Self}}" Value="Text" />
                <Setter Property="Background" Value="Pink" />
You could build a custom IValueConverter that takes a IPropertyDataAccessor and returns true (the property should be highlighted) or false (the property should not be highlighted). To do this, you'd use something like "{Binding DataContext, RelativeSource={RelativeSource Self}, Converter={StaticResource MyConverter}}" and change the value to "true".

Alternatively, you could simply return a Brush from your custom IValueConverter and bind the Background property directly. You'd replace with the MultiDataTrigger with a Trigger (with Property="DataAccessorType" Value="Property") and a single Setter that binds the Background like show in the previous paragraph. The benefit of this, is you can easily highlight various properties with different colors.

Actipro Software Support

Posted 10 years ago by Eli Obadia
Thanks a lot,
The latest build of this product (v2020.1.1) 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.