[Feature] Custom StateTriggerBase to include an IsActive bool dependency property #4621
Replies: 25 comments
-
Hello, 'XAML-Knight! Thanks for submitting a new feature request. I've automatically added a vote 👍 reaction to help get things started. Other community members can vote to help us prioritize this feature in the future! |
Beta Was this translation helpful? Give feedback.
-
Will need to name it something else to avoid confusing with the platform |
Beta Was this translation helpful? Give feedback.
-
Linking microsoft/microsoft-ui-xaml#1460 |
Beta Was this translation helpful? Give feedback.
-
Should be noted that |
Beta Was this translation helpful? Give feedback.
-
The intended usage is that that is how you trigger that specific trigger - by setting it to true. It might have been more clear if it was called |
Beta Was this translation helpful? Give feedback.
-
We're creating our own base class for the toolkit that has this property to reduce the copy-pasted boilerplate code for our own triggers, as described at the top of the issue. When WinUI figures their side out, we'll revisit our version and update as needed. |
Beta Was this translation helpful? Give feedback.
-
I'm not entirely sure I understand the problem with allowing it to be publicly settable. |
Beta Was this translation helpful? Give feedback.
-
For |
Beta Was this translation helpful? Give feedback.
-
These are the "details to iron out" I mentioned 🙂 Setting However, the main point of exposing |
Beta Was this translation helpful? Give feedback.
-
I think the original intent and problem microsoft/microsoft-ui-xaml#1460 is describing is not around trying to override the So, maybe this is a read-only DP that our own triggers can maintain the state in-sync with when they set the base Adding over-ride logic to each and every trigger we make seems a bit complex. I think that's what @dotMorten is trying to get at here. |
Beta Was this translation helpful? Give feedback.
-
I don't think we need this at all, setting IsActive just activates or deactivates the trigger temporarily. But thinking through the possible scenarios the setter could be used for -- making it readonly sounds good. |
Beta Was this translation helpful? Give feedback.
-
Which is what my proposed design suggests. Subclasses like the |
Beta Was this translation helpful? Give feedback.
-
@XAML-Knight I'm curious about this justification:
Why are the triggers doing this in the first place? |
Beta Was this translation helpful? Give feedback.
-
Should be noted that users can still set IsActive since dependency properties aren't truly readonly in UWP. Maybe still handle the changed callback and |
Beta Was this translation helpful? Give feedback.
-
I have to agree with @michael-hawker's comment in the WinUI issue, maybe |
Beta Was this translation helpful? Give feedback.
-
@Arlodotexe As already noted here: microsoft/microsoft-ui-xaml#1460 (comment) Since the |
Beta Was this translation helpful? Give feedback.
-
Again as noted in the other issue, that would be a breaking change. Secondly there are different purposes to the two. They aren't the same thing, and shouldn't be merged, as they serve different purposes. Having IsActive settable on the base class would be a huge problem for all other state triggers, as they would no longer have control over when they are active or not. |
Beta Was this translation helpful? Give feedback.
-
@Arlodotexe You thumbed my comment down. Do you care to explain why? Is there something the community toolkit can do here about a class that is defined in a completely different product, or am I misunderstanding something else that you want the community toolkit to do? |
Beta Was this translation helpful? Give feedback.
-
We aren't trying to replace the inbox The thumb down was about closing the issue based on your linked comment - much of our discussion here has been to address that specific comment. |
Beta Was this translation helpful? Give feedback.
-
@Arlodotexe Gotcha. I misunderstood the bit about introducing a second base class. |
Beta Was this translation helpful? Give feedback.
-
Actually just looked at all the state triggers in this repo. Not a single one I can see has an
|
Beta Was this translation helpful? Give feedback.
-
In my case, with Another trigger, |
Beta Was this translation helpful? Give feedback.
-
Did you see my comment in your PR about just calling |
Beta Was this translation helpful? Give feedback.
-
I'd suggest you take a second look at the |
Beta Was this translation helpful? Give feedback.
-
@XAML-Knight the This new base would allow us to refactor this. But it's doing it for the same reason so the state can be inspected from the outside vs. manipulating its logic. Also, we're not arguing, we're having a discussion. If you feel otherwise, please let me know. I think the main point (which we probably want to update in the issue description) is that we want to have the following:
I know normally we don't implement INotifyPropertyChange at the UI layer but maybe that's easier as dependency properties in UWP don't support read-only like WPF did (see microsoft/microsoft-ui-xaml#3139). |
Beta Was this translation helpful? Give feedback.
-
Describe the problem this feature would solve
A few of our triggers use their own
IsActive
Dependency Property, and so it seems like refactoring the bool property (as useful as it is) into the parent base class (StateTriggerBase
) would be in order.Describe the solution
StateTriggerBase
would be the proud new parent of a boolIsActive
dependency property (and potentially also an OnActiveChanged event), which would then be inherited by any subsequent child classes.Describe alternatives you've considered
Repeatedly adding the same boilerplate IsActive dependency property code to each trigger that needs it is not sustainable.
Additional context & Screenshots
Take a look at #1460
Beta Was this translation helpful? Give feedback.
All reactions