Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Expose IsActive and ActiveChanged event on StateTriggerBase #1460

Open
dotMorten opened this issue Oct 18, 2019 · 11 comments
Open
Labels
feature proposal New feature proposal needs-winui-3 Indicates that feature can only be done in WinUI 3.0 or beyond. (needs winui 3) team-Controls Issue for the Controls team wct

Comments

@dotMorten
Copy link
Contributor

dotMorten commented Oct 18, 2019

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

@michael-hawker
Copy link
Collaborator

Since StateTriggerBase is a DependencyObject, wouldn't it make sense for IsActive to just be a DependencyProperty too?

@dotMorten
Copy link
Contributor Author

That would make it publicly settable which I'm not sure is a good idea

@jevansaks jevansaks moved this from Needs triage to Backlog in Controls Triage Oct 21, 2019
@jevansaks jevansaks added the team-Controls Issue for the Controls team label Nov 7, 2019
@ryandemopoulos ryandemopoulos added the needs-winui-3 Indicates that feature can only be done in WinUI 3.0 or beyond. (needs winui 3) label Dec 6, 2019
@ryandemopoulos
Copy link
Member

@dotMorten Sorry for the long delay here. This was put in the Freezer, but I'm also adding the needs-winui-3 label too. As I think you know we're working to get open source asap, and once that happens I think we'll have more ability to evaluate suggestions like this. I appreciate the time you took to file it Morten.

@ryandemopoulos ryandemopoulos removed their assignment Dec 6, 2019
@dotMorten
Copy link
Contributor Author

Sorry for the long delay here

Oh no worries. I wasn't expecting it until then.

I'll be more than happy to implement it as well and submit the PR once the source is live.

@michael-hawker
Copy link
Collaborator

@dotMorten I know you have the PR open to add the StateTriggers to the toolkit, since they're more foundational - does it make more sense to wait and propose adding them to WinUI 3 instead?

@dotMorten
Copy link
Contributor Author

dotMorten commented Dec 12, 2019

@michael-hawker No I didn't propose adding those triggers to WinUI. What I'm proposing here is to add the infrastructure that allows creating much more advanced state triggers - the PR you referred to does not have these advanced triggers because of the lack of that infrastructure - hence this feature request.

@michael-hawker
Copy link
Collaborator

Yeah, maybe StateTrigger and StateTriggerBase should be a singular class?

@dotMorten
Copy link
Contributor Author

@michael-hawker I think that ship has sailed :)

@dotMorten
Copy link
Contributor Author

@ryandemopoulos Any chance this could be re-evaluated for 1.1+ ?

@Arlodotexe
Copy link

Arlodotexe commented Dec 14, 2021

Should be noted that StateTrigger already exposes an IsActive dependency property, but it's marked as sealed.

Continuing discussion for an alternative in CommunityToolkit/WindowsCommunityToolkit#4428

@dotMorten
Copy link
Contributor Author

@Arlodotexe yes because that’s how you trigger that one. For this trigger you trigger it using the Value property

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature proposal New feature proposal needs-winui-3 Indicates that feature can only be done in WinUI 3.0 or beyond. (needs winui 3) team-Controls Issue for the Controls team wct
Projects
Development

No branches or pull requests

5 participants