#316 – 改变按钮的ClickMode(Changing the ClickMode of a Button)
来源:互联网 发布:重庆旅游业数据 编辑:程序博客网 时间:2024/06/09 19:12
在Windows系统中,一般的按钮都会在点击之后执行某个操作。通常“点击”被认为是鼠标左键被“按下”然后“释放”这一连续动作的组合,而和按钮相关联的操作会在“释放”动作结束后触发。
在WPF中,你可以通过改变Button.ClickMode 属性改变 Click 事件触发的时间。ClickMode 的值为一下的枚举:
-ClickMode.Release – 当释放鼠标按键的时候触发Click 事件(默认)
-ClickMode.Press – 当按下鼠标按键的时候触发Click 事件
-ClickMode.Hover – 当鼠标悬停在按钮上的时候触发Click 事件
<StackPanel> <Button Content="Release" ClickMode="Release" Height="30" Width="100" Margin="15" Click="Button_Click"/> <Button Content="Press" ClickMode="Press" Height="30" Width="100" Margin="15" Click="Button_Click"/> <Button Content="Hover" ClickMode="Hover" Height="30" Width="100" Margin="15" Click="Button_Click"/> <Label Name="lblInfo" Margin="15"/></StackPanel>
private int clickNum = 1;private void Button_Click(object sender, RoutedEventArgs e){ Button b = sender as Button; lblInfo.Content = string.Format("Click {0}, Mode {1}", clickNum++, b.ClickMode.ToString());}
上面的例子中有三个按钮,每个按钮对应一种触发Click事件的方式,每次触发Click事件后,lblInfo显示的次数就会加1。
原文地址:https://wpf.2000things.com/2011/06/08/316-changing-the-clickmode-of-a-button/
0 0
- #316 – 改变按钮的ClickMode(Changing the ClickMode of a Button)
- Changing the sharing of a project
- Changing the Thickness of the Stroking Pen:改变画笔的厚度
- Changing the default skins on a Button control in Flex
- The Changing Face of Business Intelligence(正在改变中的BI的脸)一
- The Changing Face of Business Intelligence(正在改变中的BI的脸)二
- OpenERP-隐藏多对多域弹出列表视图的"新建"按钮(Hide the "Create" button from the popup list view of a many2many field)
- Changing the Title of a Print Dialog in Delphi
- Changing the layout direction of a form item in Flex
- Changing the rendering mode of a shared page
- #711 – 在拖拽的过程中改变鼠标样式(Changing the Mouse Cursor While Dragging)
- #221 – Changing a Brush at Run-Time(在Run-Time的时候改变画刷)
- 14.5.2 Changing the Number or Size of InnoDB Redo Log Files 改变InnoDB Redo Log Files的数量
- 改变颜色按钮(color button)的颜色
- 16. 5. 3. 改变Stroke厚度-Changing the Thickness of the Stroking Pen
- The changing marketplace of bioinformatics
- Changing the ID of Dynamixel
- Changing the Framework version requires a restart of the W3SVC service.
- 二.C++学习笔记-模板
- 修改状态栏颜色
- LevelDB详解
- 通过可视化来了解你的Spark应用程序
- react-native组件笔记
- #316 – 改变按钮的ClickMode(Changing the ClickMode of a Button)
- ElasticSearch:QueryParsingException: [my-index] failed to find geo_point field [position] 解决
- 设计模式之单例模式(singleton)C++
- 360面试题——搜索二叉树转换成有序的双向链表
- 推荐系统开源软件列表汇总和点评
- Java Executor并发框架(八)Executor框架线程池ThreadPoolExecutor、ScheduledThreadPoolExecutor
- 程序跳转到 mainret = main(argc, argv, envp); 抛出异常Unhandled exception
- 解决android.content.res.ResourcesNotFoundException
- shell基础(一)