0
votes

What is the most recommended event to use for listbox items. I have three static items in my list and this should navigate to a page upon clicking. I know that there's no click event for listbox items or listbox. Then I will bind it in my View Model. What I have in mind is the selected event, is it correct? Also for the method used for binding how is the syntax of navigation when an item is selected? Thanks much in advance!

<ListBox x:Name="lbviewlist">
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Selected">
            <Command:EventToCommand Command="{Binding ViewListCommand}"/>
        </i:EventTrigger>
    </i:Interaction.Triggers>
    <ListBox.Items>
        <ListBoxItem Content="By product" FontSize="25"/>
        <ListBoxItem>By Vendor</ListBoxItem>
        <ListBoxItem>By Best Combination</ListBoxItem>
1

1 Answers

0
votes

There are two ListBox-events that can achieve this:

In both cases you can get the item through the SelectedIndex or SelectedItem property. Hope this gets you on the way.