Customizing the color of readonly items.

Grids for WPF Forum

Posted 10 years ago by Kelly Leahy - Software Architect, Milliman
Version: 4.5.0487
Avatar
We are using the property grid in a situation where all of the properties (except one) are readonly for items in this view. Since everything is readonly it is very distracting to use the 'read only color' for these properties.

From reading through the docs a bit it seems there are several approaches whereby we could use the same color for all items:

1) retemplate part of the control (seems hard, but this is the preferred WPF way of doing things generally)
2) apply a style to TextBlock at the PG level (doesn't seem to work)
3) create custom editors for these fields and set the NameTemplate and ValueTemplate for them (not sure how to do this and really seems like overkill)
4) create a resource with the appropriate style key in our resource dictionary (don't know if this would work, but it would be really nice if it did).
5) set the PG to IsReadOnly and then write a custom editor for the single property that we want to be read/write that ignores the IsReadOnly property.

How would you recommend we proceed?

Kelly Leahy Software Architect Milliman, USA

Comments (3)

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

The brush used to render the name cells as "read-only" is controlled by themes:PropertyGridCommonDictionary.ForegroundDisabledBrushKey. So you could defined a new brush in your Window/app resources to override the default value.

The value cells are actually using the SystemColors.GrayTextBrushKey, so you would only be able to change those by using #2 (applied to the ComboBox/TextBox controls) or #3 options above.

I've added an item to our TODO list to update the value cells to use a component resource kye in the PropertyGridCommonDictionary also, so that it would be easier to configure.

Hope this helps.


Actipro Software Support

Posted 4 years ago by Andrew Hanlon
Avatar

I see that this topic is quite old, but I have the same requirement to show read-only values more cleary. I can see that the foreground colour is controlled by the `themes:AssetResourceKeys.ControlForegroundDisabledBrushKey` brush, however there also appears to be a semi-opaque colour added over top of the value. I have searched through the xaml but cannot see where this is being set (ValueCellContainerStyle, editor, textbox itself). I should mention I am using the Metro Light theme. Thanks, 

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

Hi Andrew,

If you mean in the value cells only, then most of our themes use the brush you mentioned.  That is also assuming you have our native control themes enabled too.  Otherwise it might be the native WPF control templates for controls like TextBox that are used in the value cells.  When you enabled our native control themes, we provide custom themes for native controls that use our resource brushes, which makes for a more consistent look across your app.  I'm not sure what the semi-opaque color overlay would be without seeing an example.

If you need us to look into it further, please make a new simple sample project that shows the issue and email that to our support address.  In the email, mention this thread and rename the .zip file extension of what you send so it doesn't get spam blocked. 


Actipro Software Support

The latest build of this product (v2019.1 build 0681) was released 18 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.