MultiDataTrigger with condition using another property

Grids for WPF Forum

Posted 11 years ago by Tom Laverty
Version: 12.2.0571
Avatar

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">
    <Style.Triggers>
        <MultiDataTrigger>
            <MultiDataTrigger.Conditions>
                <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" />
            </MultiDataTrigger.Conditions>
            <Setter Property="propgrid:PropertyGrid.IsReadOnly" Value="True" />
            <Setter Property="Background" Value="LightGray"/>
        </MultiDataTrigger>
    </Style.Triggers>
</Style> 

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

Regards,

Tom

Comments (1)

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

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 (v24.1.2) was released 7 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.