Context Menu of WPF ListView


When an user interface contain too many buttons, a user cannot comfort to handle this and i think it is not a good design.For this reason i try to remove some button which button actually need for editing,deleting operation for Listview.In this situation The Context Menu is the perfect solution.
here is the XAML Code

<ListView BorderBrush="#FFA8CC7B" Height="133" HorizontalAlignment="Left" Margin="88,382,0,0" Name="lvInvDetails" VerticalAlignment="Top" Width="596">
            <ListView.ContextMenu>
                <ContextMenu Name="InvoiceDetailsList" StaysOpen="true" Background="WhiteSmoke">
                    <ContextMenu.BitmapEffect>
                        <BitmapEffectGroup/>
                    </ContextMenu.BitmapEffect>
                    <MenuItem Header="Edit" Name="EditIVD" Click="EditIVD_Click" />
                    <MenuItem Header="Remove" Name="RemoveIVD" Click="RemoveIVD_Click" />
                </ContextMenu>
            </ListView.ContextMenu>
            <ListView.View>
                <GridView>
                    <GridViewColumn DisplayMemberBinding="{Binding Path=InvoiceDetailsItemId}" Header="Item Id" Width="90" />
                    <GridViewColumn DisplayMemberBinding="{Binding Path=InvoiceDetailsItemName}" Header="Item Name" Width="120" />
                </GridView>
            </ListView.View>
        </ListView>

If you have any query about this topic please leave a comment.

Advertisements

3 Responses to “Context Menu of WPF ListView”

  1. Nabab Says:

    helpful site

  2. Angelo Riganis Says:

    Very helpful entry, but it would be interesting to know how to make the context menu appear when right-clicking an item of the list only.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: