I want to pass the current DataContext (which is an instance of a ViewModel) as a CommandParameter on a WPF Button. What would be the syntax I should use?
<Button x:Name="btnMain" Command="infra:ApplicationCommands.MyCommand" CommandParameter="{Binding ???}" />
An empty Binding, without a path, binds directly to the DataContext, so
{Binding}
is enough to make it work! Your example:
<Button x:Name="btnMain" Command="infra:ApplicationCommands.MyCommand" CommandParameter="{Binding}" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With