MultiDataTrigger with condition using another property

Grids for WPF Forum

Posted 6 years ago by Tom Laverty
Version: 12.2.0571

I'm using implicit styles in my propgrid and I have some cases where I want the style of one property dependent on another property. I see in the quick starts how this can be done in the view model by exposing properties and binding them (with associated NotifyPropertyChange, etc) but I'd like to keep this in the xaml (my view model classes are dynamically generated so adding logic using the MethodBulder, etc. is harder).

I see examples where logic is bound to an ancestor in the visual model but can I bind to a sibling property? (I know the property name and display name of the sibling)

Some examples of cases I'd like to support:

- bind readonly/background color of one property based on IsSelected value of another checkbox property (using the built-in editor/CheckBoxValueTemplateKey template)

- bind readonly/background color of one property based on selected item value of a sibling combobox bound to an enumerated type

Here's an incomplete example:


<Style TargetType="propgrid:PropertyGridDataAccessorItem">
                <Condition Binding="{Binding DataAccessorType, RelativeSource={RelativeSource Self}}" Value="Property" />
                <Condition Binding="{Binding ValueName, RelativeSource={RelativeSource Self}}" Value="Address2" />
                <Condition Binding="{Binding IsSelected, What goes here? }" Value="True" />
            <Setter Property="propgrid:PropertyGrid.IsReadOnly" Value="True" />
            <Setter Property="Background" Value="LightGray"/>

Sorry if this is a basic xaml binding question but I have a lot to learn in that area!



Comments (1)

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

Hi Tom,

It doesn't look like the data accessors have anything on them that let you get to child data accessors.  They just seem to point up to their parent.  I wonder if you could bind to the Parent of the current item's data accessor (our sample show getting the current item data accessor), then get the Value of that parent data accessor (which should be your data object) and hit the desired property off that.  I'm not sure if that will work or not but you can give it a try.

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.