readonly property

Grids for WPF Forum

Posted 8 years ago by Dude4
Version: 11.1.0541
Avatar
Is there a way to dynamically change the readonly ability of a specific property? Not the whole property grid. The readonly attribute is static.

Comments (1)

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

There are a few ways to go about this. The easiest would be to simply set the propgrid.PropertyGrid.IsReadOnly attached property on the specific item you want to make read-only. For example, this Style would make the Text property read-only:
<Style TargetType="propgrid:PropertyGridDataAccessorItem">
    <Style.Triggers>
        <MultiDataTrigger>
            <MultiDataTrigger.Conditions>
                <Condition Binding="{Binding DataAccessorType, RelativeSource={RelativeSource Self}}" Value="Property" />
                <Condition Binding="{Binding ValueName, RelativeSource={RelativeSource Self}}" Value="Text" />
            </MultiDataTrigger.Conditions>
            <Setter Property="propgrid:PropertyGrid.IsReadOnly" Value="true" />
        </MultiDataTrigger>
    </Style.Triggers>
</Style>
You would bind the attached property to the underlying object (i.e. {Binding DataContext.Target.SomeProperty, RelativeSource={RelativeSource Self}}) or even build a custom IPropertyDataAccessor whose IsReadOnly property is dynamic. The latter option would also require a custom DataFactory.


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.