Click here to Skip to main content
15,910,981 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I am working in wpf. My problem is that when I right click on scrollbar (Listview's scrollbar,Datagrid's Scrollbar)There is opening a contextmenu (Scroll Here,Scroll Up...).
I want to hide this or disable this contextmenu. If there is any way to do this please suggest me.
Posted
Updated 9-Apr-18 21:15pm

C#
<window x:class="Window1" xmlns:x="#unknown">
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300">
    <grid>
 <Listview name="listview">
        <scrollbar>
            <scrollbar.contextmenu>
                <contextmenu visibility="Collapsed" />
            </scrollbar.contextmenu>
        </scrollbar>
 </Listview>
    </grid>
</window>
 
Share this answer
 
v2
ContextMenuService.IsEnabled="False"
 
Share this answer
 
Here is my solution:

Hook a MouseRightButtonUp event handler to ListView/DataGrid/Listbox, and then set e.Handled = true.

In that case, the Mouse Right Button Up event will stop tunnelling to Scrollbar.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900