Go Wpf--thumb

Source: Internet
Author: User

A thumb class that represents a control that can be dragged by the user. Its main three events were dragdelta,dragstarted,dragcompleted.

dragdelta--when a Thumb control has logical focus and mouse capture, it occurs one or more times as the mouse position changes.

dragstarted--occurs when the Thumb control receives logical focus and mouse capture.

dragcompleted--occurs when the Thumb control loses mouse capture.

 1 <window.resources> 
2 <resourcedictionary>
3 <controltemplate x:key= "Template1" &G T
4 <ellipse width= "height=";
5 <ellipse.fill>
6 <solidcolorbrush color= "Black" ></SOLIDCOLORBRUSH>
7 </ellipse.fill
8 </ellipse>
9 </controltemplate>
</RESOURCEDICTIONARY&G T
one </window.resources>

<canvas name= "MyCanvas";
<thumb name= "Mythumb" Drag Delta= "Ondragdelta" background= "Blue" dragstarted= "mythumb_dragstarted" dragcompleted= "mythumb_dragcompleted"
canvas.left= "0" canvas.top= "0" width= "height=" "/>";

<!--template= "{STATICR Esource Template1} ", if this method is used to bind the thumb template, it is not possible to change the background of the--> through the dragstarted,dragcompleted event;
</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 }

9 private void Mythumb_dragstarted (object sender, Dragstartedeventargs e)
Ten {
One mythumb.background = Brushes.orange;
-- }

+ private void mythumb_dragcompleted (object sender, DragCompletedEventArgs e)
{
mythumb.background = Brushes.blue;
+ }

Go Wpf--thumb

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.