Replies: 1 comment
-
You shouldn't need to set the CommandParameter property as per this example in our docs: https://learn.microsoft.com/en-us/dotnet/communitytoolkit/maui/behaviors/event-to-command-behavior#c-markup |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In net 8 Markup 4.1 (Didn't try Net 9, too buggy yet)
In XAML, an eventtocommand behavior needs a cast:
<Entry.Keyboard>
<x:Arguments>
Suggestions
</x:Arguments>
</Entry.Keyboard>
<Entry.Behaviors>
<mct:EventToCommandBehavior
x:TypeArguments="system:EventArgs"
Command="{Binding UnfocusedEmailCommand}"
EventName="Unfocused" />
</Entry.Behaviors>
In Markup, all I can find is something like this:
var behavior = new EventToCommandBehavior
{
EventName = nameof(CollectionView.SelectionChanged),
Command = _vm.TappedCommand,
CommandParameter = new Binding("SelectedItem", source: collectionView)
};
Where the binding will take an element selected in a collection view.
It will compile but will have the error:
Parameter "parameter" (object) cannot be of type Microsoft.Maui.Controls.Binding, as the command type requires an argument of type System.EventArgs. (Parameter 'parameter')
That happens very deep in the stack in, at least, Windows and Android (haven't tested in iOS and MacCat)
This seems quite similar to the x:TypeArguments noted above.
Questions:
How can I cast in Markup the same way I'm doing it in Xaml?
Or
How can I pass a command parameter that works?
DashboardMarkup.zip
DashboardVM.zip
monthly_sales.zip
Beta Was this translation helpful? Give feedback.
All reactions