Wpf ScrollViewer 右键菜单禁用
来源:互联网 发布:恒大淘宝内部组织架构 编辑:程序博客网 时间:2024/05/18 03:41
直接对ScrollViewer进行 ContextMenu="{x:Null}" 是不能禁用掉ScrollViewer默认的右键菜单的。
ScrollViewer内部由好部分组成,而右键菜单是由其中的ScrollBar触发的,所以对ScrollViewer进行 ContextMenu="{x:Null}"是无效的。
如图 ScrollViewer 内部的实现:
<ControlTemplate x:Key="ScrollViewerControlTemplate2" TargetType="{x:Type ScrollViewer}"> <Grid x:Name="Grid" Margin="0,-1,-2,-1" Background="{TemplateBinding Background}"> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="7"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="*"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Rectangle ContextMenu="{x:Null}" x:Name="Corner" Grid.Column="1" Fill="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" Grid.Row="1"/> <ScrollContentPresenter ContextMenu="{x:Null}" x:Name="PART_ScrollContentPresenter" CanContentScroll="{TemplateBinding CanContentScroll}" CanHorizontallyScroll="False" CanVerticallyScroll="False" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Grid.Column="0" Margin="{TemplateBinding Padding}" Grid.Row="0"/> <ScrollBar ContextMenu="{x:Null}" x:Name="PART_VerticalScrollBar" AutomationProperties.AutomationId="VerticalScrollBar" Cursor="Arrow" Grid.Column="1" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Grid.Row="0" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}" Style="{DynamicResource ScrollBarStyle2}"/> </Grid> </ControlTemplate>
将红色部分代码加上ContextMenu="{x:Null}" 才能禁用右键菜单。
0 0
- Wpf ScrollViewer 右键菜单禁用
- 禁用文本框右键菜单
- 禁用右键菜单
- 浏览器禁用右键菜单
- WPF中的右键菜单.
- WPF 右键菜单动画
- WPF 右键菜单
- WPF 创建右键菜单
- WPF中的右键菜单.
- WPF添加右键菜单
- 关于js禁用右键菜单
- html页面右键菜单禁用
- js中禁用右键菜单
- ckeditor禁用右键菜单显示
- html页面右键菜单禁用
- WPF下实现右键菜单
- WPF 自定义右键菜单样式
- WPF中的右键菜单ContextMenu
- 玩转RecyclerView
- oj2520: 小慧唱卡拉OK
- 软件测试面试常考点
- 【设计模式】策略模式
- 08:字符三角形
- Wpf ScrollViewer 右键菜单禁用
- C/C++ 引用,赋值,指针之间的区别
- NSIS知识技巧
- 接口和抽象类
- H.264格式分析
- 回车键替换Tab键完成循环索引功能。
- Android 中 selector 选择器的使用
- Spring IOC和AOP 原理彻底搞懂
- windows7电脑远程连接问题