Skip to content

Proposal: Expose IsActive and ActiveChanged event on StateTriggerBase #1460

@dotMorten

Description

@dotMorten

Proposal: Expose bool IsActive and ActiveChanged event on StateTriggerBase.

Summary

It's currently impossible to build composite state triggers because whether a state trigger is active or not can't be monitored, limiting their usage.

Rationale

I found it very useful in the WindowsStateTriggers repo, as I could make triggers that would trigger based on or/and/xor conditions of multiple triggers. I had to however add my own interface to my triggers to expose the Active property and ActiveChanged event, meaning my composite trigger weren't compatible with other 3rd and 1st part state triggers. It created some interesting capabilities like enabling/disabling UI if too many check boxes were checked etc.

Scope

Add the following to StateTriggerBase:

		/// <summary>
		/// Gets a value indicating whether this trigger is currently active.
		/// </summary>
		/// <value><c>true</c> if this trigger is active; otherwise, <c>false</c>.</value>
		public bool IsActive { get; }
		/// <summary>
		/// Occurs when the <see cref="IsActive"/> property has changed.
		/// </summary>
		public event EventHandler IsActiveChanged;

Important Notes

Here's an example how exposing these values allows more complex state triggers, by combining multiple"
https://github.com/dotMorten/WindowsStateTriggers/blob/3a97a7a45b9c997e4f59e4afd98dc1ee7e0d8a49/src/TestApp/Samples/CompositeSample.xaml#L13-L49
windowsstatetriggers

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature proposalNew feature proposalneeds-winui-3Indicates that feature can only be done in WinUI 3.0 or beyond. (needs winui 3)team-ControlsIssue for the Controls teamwct

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions