-
-
Notifications
You must be signed in to change notification settings - Fork 144
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
ActionExtension for events does not respect guard proeprty #55
Comments
Because events have no concept of "can execute". ICommand has the CanExecute method, but events have nothing of the sort. There's no way to disable a button using only it's If you want to prevent your event handler from running in particular cases, put the code |
That's true that the control cannot (and should not) be disabled. That said, from view-model level of abstraction, since Stylet effectively removes the concept of PS: I'm already doing |
Also, to further iterate my point, <i:Interaction.Triggers>
<i:EventTrigger EventName="SomeEvent">
<i:InvokeCommandAction Command="{Binding Path=SomeCommand, Mode=OneWay}"/>
</i:EventTrigger>
</i:Interaction.Triggers> It will respect the |
I disagree - Stylet tries to avoid introducing too much magic. Someone reading a project written with Stylet shouldn't have to do too much guessing/reading to figure out what's going on. Guard properties are already about as much magic as I'm comfortable with (they only exist because they're so convenient). Developers already have to care about the difference between events and ICommands, as the latter can disable controls and the former can't. Letting guards have different behaviour based on whether they're applied to an event or ICommand just makes things more confusing. |
You could also argue that because "Guard properties are already enough magic" I initially didn't expect and found it unintuitive that guard properties were completely ignored with events. Also coming from the "non-magic" background, I expected it to work the way it does with |
From wiki:
Why? I want to be able to set
MouseLeftButtonUp="{s:Action SomeAction}"
and only have the handler actually execute when the guard property lets it. The justification is that I want to be able to use events in the same way I use commands, without having to use some kind ofEventToCommand
contraption.The text was updated successfully, but these errors were encountered: