question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Implement MultiDataTrigger like WPF in Style

See original GitHub issue

I can’t implement a function similar to the MultiDataTrigger in the Avalonia Style. In WPF, it looks like:

<MultiDataTrigger>
    <MultiDataTrigger.Conditions>
        <Condition Binding="{Binding IsPressed, RelativeSource={RelativeSource Self}, Mode=OneWay}"
                   Value="True" />
        <Condition Binding="{Binding Path=(local:CustomHelper.PressedForeground), Converter={StaticResource {x:Static IsNonnullConverter}}, RelativeSource={RelativeSource Self}, Mode=OneWay}"
                   Value="True" />
    </MultiDataTrigger.Conditions>
    <Setter TargetName="BdrMain"
            Property="Background"
            Value="{Binding Path=(local:CustomHelper.PressedForeground), RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}" />
</MultiDataTrigger>

Is there a similar implementation in Avalonia?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
maxkatz6commented, Jul 23, 2021

Instead of {StaticResource IsNotnullConverter} you can use {x:Static ObjectConverters.IsNotNull} - build in converter.

1reaction
maxkatz6commented, Jul 23, 2021
  1. You can define class having boolean binding:
<Border Classes.my-class="{Binding Property, Converter={x:Static Converter}}" />
  1. Then you can combine selectors in styles:
<Style Selector="Border[IsPressed=True].my-class">
   <Setter />
</Style>

It’s not exactly the same, but allow to implement quite a lot.

but I did not find anything similar to MultiDataTrigger. Moreover, I’m not sure that this can be used to change the Selector

To change property - use ChangePropertyAction, to set class (and trigger style selector) - use AddClassAction. I am not sure if there are composite triggers with Or/And conditions, but I would expect it. @wieslawsoltes

Read more comments on GitHub >

github_iconTop Results From Across the Web

WPF MultiTrigger and MultiDataTrigger
There are two types of multi triggers: The MultiTrigger, which just like the regular Trigger works on dependency properties, and then the MultiDataTrigger, ......
Read more >
What's the right way to trigger on multiple conditions in a ...
How can I provide multiple conditions for data trigger in WPF? ... How to use MultiDataTrigger to check a single condition to be...
Read more >
MultiTriggers And MultiDataTriggers In WPF
You can use MultiDataTrigger in this case. It works with the bound value from ViewModel or code-behind rather than dependent on control's ...
Read more >
MultiDataTrigger Class (System.Windows)
A MultiDataTrigger object is similar to a MultiTrigger, except that the conditions of a MultiDataTrigger are based on property values of bound data...
Read more >
MultiDataTrigger.Conditions Property (System.Windows)
A MultiDataTrigger object is similar to a MultiTrigger, except that the conditions of a MultiDataTrigger are based on property values of bound data...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found