Feature request: Trigger support
See original GitHub issueIf I understand correctly, there are no Triggers in Avalonia right now. I think it would be beneficial to support them since they allow for dynamic UI that’s dependant on a model or another control’s state.
Here are few examples of how I use Triggers in my projects. The syntax is Ammy, but I think it’s understandable enough.
alias TopBarButton(buttonName) {
Button {
Style: Style {
TargetType: Button
Triggers: [
@DataTrigger_SetProperty(bind "SelectedView", $buttonName, "BorderThickness", "1")
]
}
}
}
This trigger watches SelectedView
property on a ViewModel and when it equals $buttonName
(passed parameter), it would set BorderThickness
to 1.
Or even something like this, which changes the Button
s content depending on IsCollapsed
property:
Style: Style {
TargetType: Button
#Setter("Content", "▲")
#Add_DataTrigger_SetProperty(bind IsCollapsed, true, "Content", "▼")
}
In some cases, you can replace triggers with Binding Converters, but it is more cumbersome, and not always possible (for example if you set the ControlTemplate
).
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:24 (14 by maintainers)
Top Results From Across the Web
Feature Request: Trigger Sub-Grouping Structure
This feature request is for adding the ability to have sub-grouping for Triggers. USE CASE Today, I am currently using the grouping for......
Read more >Trigger condition - Add (assignee) to 'Current user'
In Trigger conditions 'Current user' has (agent), (end-user), and all agents listed by name. When I want to create a trigger using condition ......
Read more >Hubspot Feature Request - Trigger for Customer Review ...
Seeking Help: Hubspot Feature Request - Trigger for Customer Review Automations ... with Hubspot's capabilities and I'm seeking help for a missing feature....
Read more >Feature Request: Add a real time based trigger for rules
The title of your request mentions “real time based trigger” but the body only asks for a rule that runs nightly.
Read more >Use OAuth support for HTTP request triggers
This URL was typically used by developers to trigger workflows from within their own applications or services. This feature provides added ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve tried @grokys solution in Avalonia 0.9.3 and it doesn’t work:
throws
Error Unexpected token EqualSign (line 20 position 33) Line 20, position 33.
Andthrows
Quote characters out of place (line 20 position 33) Line 20, position 33.
I’ve taken a look at the Avalonia homepage about bindings and styling https://avaloniaui.net/docs/styles/ but something like this isn’t mentione there.
How can I achieve / convert a WPF application code where I change the background of a button via datacontext binding (without converter):
@Xarlot please note that we’ve not made a decision to not include triggers, we’re just exploring alternatives.
I’ve taken a look at your examples and a lot of that can already be done in Avalonia even without conditional bindings. You just need to take advantage of our styling system. However I’ll add in conditional bindings using the invented syntax above for the stuff that can’t currently be done:
WPF:
Avalonia:
WPF:
Avalonia:
WPF:
Avalonia: