Thumb类,表示可由用户拖动的控件。其主要三个事件分别DragDelta,DragStarted,DragCompleted.

DragDelta——当 Thumb 控件具有逻辑焦点和鼠标捕获时,随着鼠标位置更改发生一次或多次。

DragStarted——在 Thumb 控件接收逻辑焦点和鼠标捕获时发生。

DragCompleted——在 Thumb 控件失去鼠标捕获时发生。

 1  <Window.Resources>
2 <ResourceDictionary>
3 <ControlTemplate x:Key="template1">
4 <Ellipse Width="60" Height="30">
5 <Ellipse.Fill>
6 <SolidColorBrush Color="Black"></SolidColorBrush>
7 </Ellipse.Fill>
8 </Ellipse>
9 </ControlTemplate>
10 </ResourceDictionary>
11 </Window.Resources>
12
13 <Canvas Name="myCanvas">
14 <Thumb Name="myThumb" DragDelta="onDragDelta" Background="Blue" DragStarted="myThumb_DragStarted" DragCompleted="myThumb_DragCompleted"
15 Canvas.Left="0" Canvas.Top="0" Width="200" Height="200"/>
16
17 <!--Template="{StaticResource template1}",若此处采用此种方法为Thumb绑定模版,是无法通过DragStarted,DragCompleted事件来改变其背景的-->
18 </Canvas>
 1    void onDragDelta(object sender, DragDeltaEventArgs e)
2 {
3 Canvas.SetLeft(myThumb, Canvas.GetLeft(myThumb) + e.HorizontalChange);
4
5 Canvas.SetTop(myThumb, Canvas.GetTop(myThumb) + e.VerticalChange);
6
7 }
8
9 private void myThumb_DragStarted(object sender, DragStartedEventArgs e)
10 {
11 myThumb.Background = Brushes.Orange;
12 }
13
14 private void myThumb_DragCompleted(object sender, DragCompletedEventArgs e)
15 {
16 myThumb.Background = Brushes.Blue;
17 }

最新文章

  1. New Year&#39;s resolution for 2016
  2. C#创建socket服务
  3. 大话设计模式C++版——抽象工厂模式
  4. AngularJs定制样式插入到ueditor中的问题总结
  5. &lt;a&gt;标签跳转传值。
  6. android xutils
  7. static inline
  8. BootStrap table 传递搜索参数
  9. DEDE栏目内容调用
  10. thinkphp批量删除的实现
  11. python中逐行读取文件的最佳方式_Drupal_新浪博客
  12. iOS开发讯飞语音的集成
  13. fmt标签格式化数字和时间
  14. PHP 工厂模式 实例讲解
  15. Python 实现接口类的两种方式+邮件提醒+动态导入模块+反射(参考Django中间件源码)
  16. iOS中蓝牙的使用
  17. jeecg字典表—普通表
  18. DG搭建方式区分
  19. “全栈2019”Java多线程第三十四章:超时自动唤醒被等待的线程
  20. React Native(三)——推送jpush-react-native

热门文章

  1. c# ToString()格式大全(转)
  2. CocoaPods更新2018年11月06日16:06:48
  3. Ulimit 文件配置
  4. Shiro术语
  5. java 读取mysql中数据 并取出
  6. js用document.getElementById时要注意!
  7. JAVA API about HTTP 3
  8. iOS开发系列-weak与unsafe_unretained修饰符
  9. 2019-9-11-在-P2P-文件分享应用以文件或文件段为单位的优缺
  10. Repeater 分页