Use of the WPF-slider Control

Source: Internet
Author: User

To use slider to implement a very simple function, you can use a label to display a value when dragging. This feature is actually extremely simple, but it took me one hour.

At first, I didn't know that the slider was not displayed. I dragged a slider and set it to run it. I found that there was nothing bare, so I wanted to find the slider attribute. There are too many helplessness, and I will not understand it at half past one. Search for an articleArticleIntroduction autotooltip: The http://www.cnblogs.com/TianFang/archive/2009/07/04/1517027.html settings are displayed on the slider when you drag the runtime discovery, not what I want. Continue to find, and then there is an article about binding: http://www.diybl.com/course/4_webprogram/asp.net/netjs/2008624/128053.html results read for a long time, is bound to the textbox, can you bind on the label I did not try, also feel unnecessary. I only need to display and do not need to bind to each other. Continue to find, there is an article on msdn about label content can "Data Binding": http://msdn.microsoft.com/zh-cn/library/cc295312.aspx results how I try, did not find a drop-down list of content.

In fact, the most I want to find is the selectedchanged event like ListBox and ComboBox, and the result is actually found, valuechanged. But a new problem arises,

Private void slidervalue_valuechanged (Object sender, routedpropertychangedeventargs

  E) {value = (INT) E. newvalue; txtbvalue. Text = value. tostring ();}

Txtbvalue. Text (textblock) is not acceptable! "The object is not set to reference instance .", I am afraid this is the most common and annoying mistake. I can't figure out what went wrong. Debugging is also unclear. Later I remembered that my slider was placed on the textblock, and there were different controls, and I didn't trigger this changed event. Try again anyway. The reason is true. The problem is solved. The specific reason is that it will be well studied later.

I haven't written a blog for a long time, so I really don't have time.

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.