microsoft / XamlBehaviors

This is the official home for UWP XAML Behaviors on GitHub.
MIT License
692 stars 110 forks source link

NavigationViewItem with Command #220

Open FlorentVllasa opened 3 years ago

FlorentVllasa commented 3 years ago

Is there a way to assign a command or method to a NavigationViewItem inside a NavigationView? I couldnt find soemthing in the samples section.

Thanks

Ika59 commented 10 months ago

As Content, we specify UIElement, which can call commands directly, for example, Button:

            <NavigationViewItem>
                <NavigationViewItem.Icon>
                    <FontIcon  Style="{StaticResource EmojiFontIconStyle}" Glyph="{StaticResource Emoji_Command_WhatsNew}"/>
                </NavigationViewItem.Icon>
                <NavigationViewItem.Content>
                    <Button x:Name="WhatsNew_Button" Content="Whats new?" Style="{StaticResource AccentButtonStyle}" Command="{x:Bind ViewModel.AppCommands.WhatsNew_Command}" CommandParameter=""/>
                </NavigationViewItem.Content>
            </NavigationViewItem>
Ika59 commented 10 months ago

I put the real code in the running program!