Question

I am playing around with the context menu, i have installed the toolkit and i'm trying my first example with a listbox binded to a observable collection, in the item template i have the view of a item and the context menu, but it doesn't appear. :/ Here's the code

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        <ListBox x:Name="List" ItemsSource="{Binding Friends}" >
            <ListBox.DataContext>
                <ViewModel:MainViewModel/>
            </ListBox.DataContext>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <View:FriendItemView />
                    <toolkit:ContextMenuService.ContextMenu>
                        <toolkit:ContextMenu x:Name="Menu" Background="Black" >
                            <toolkit:MenuItem x:Name="Edit" Header="Edit" />
                            <toolkit:MenuItem x:Name="Delete" Header="Delete"/>
                        </toolkit:ContextMenu>
                    </toolkit:ContextMenuService.ContextMenu>
                </DataTemplate>
            </ListBox.ItemTemplate>

        </ListBox>
    </Grid>
Was it helpful?

Solution

Try to put the ContextMenu inside the FriendItemView.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top