ReadOnly state on a category

Grids for WPF Forum

Posted 10 years ago by shlomi R
Version: 9.2.0510
Avatar
Hi, is there any way to set all the properties inside a specific category to read only mode based on another property value?

Comments (2)

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

That is certainly possible. The built-in property editors (as well as the Editors for WPF interop property editors) check the attached and inheirted PropertyGrid.IsReadOnly property. So what you can do is create an implicit Style for PropertyGridDataAccessorItem (which displays all items in the PropertyGrid), that binds the attached property to some value. The example below shows how to bind the attached property for a specific category, but you could modify to just use a Trigger so it's applied to all categories.
<propgrid:PropertyGrid ...>
    <propgrid:PropertyGrid.Resources>
        <Style TargetType="{x:Type propgrid:PropertyGridDataAccessorItem}">
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="DataAccessorType" Value="Category" />
                    <Condition Property="DisplayName" Value="MyCategoryName" />
                </MultiTrigger.Conditions>
                <Setter Property="propgrid:PropertyGrid.IsReadOnly" Value="{Binding ...}" />
            </MultiTrigger>
        </Style>
    </propgrid:PropertyGrid.Resources>
    ...
</propgrid:PropertyGrid>
Once you set the attached property, the editors inside the category should be read-only.


Actipro Software Support

Posted 10 years ago by shlomi R
Avatar
Thanks, it was very helpful.
The latest build of this product (v2019.1 build 0683) 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.