Windows 8 utility tip series: 8. Slider control and ToggleSwitch control in Windows 8

Source: Internet
Author: User

I:SilderA slider control also exists in Silverlight. It is mainly used for volume adjustment, brightness adjustment, color adjustment, and thermometer.

    Main attributes:

FlowDirection: slide from left to right or from right to left

Minimum: Minimum value

Maximum: Maximum Value

Orientation: vertical or horizontal

TickFrequency: The value between scales when the Slider length permits

TickPlacement: the position where the scale is displayed, either above or below the Slider or in the Slider.

    Main events:ValueChanged: this event is triggered when the value changes

    Xaml and Cs code:

        <TextBlock HorizontalAlignment="Left" Margin="471,127,0,0" Name="tbText"                   TextWrapping="Wrap" Text="" VerticalAlignment="Top" Height="18" Width="200"/>        <Slider HorizontalAlignment="Left" Value="10"  Name="slider1" FlowDirection="LeftToRight"                Minimum="0" Maximum="100" Orientation="Vertical"                TickFrequency="5" TickPlacement="BottomRight"                Margin="701,127,0,0" VerticalAlignment="Top" Height="500" Width="43"/>
Public MainPage () {this. initializeComponent (); this. slider1.ValueChanged + = sliderincluvaluechanged;} void sliderincluvaluechanged (object sender, RangeBaseValueChangedEventArgs e) {this. tbText. text = "New Value of the Slider control:" + e. newValue + "old value:" + e. oldValue ;}

II:ToggleSwitchThe control is a switch control. The WIFI switch in Windows 8 also uses this control. It can also be used as a volume switch.

    Main attributes:

OffContent: the name of the operation to be performed when it is disabled, such as enable, Open, and enable

OnContent: the name of the operation to be performed when the status is enabled, such as Close, Close, or disable.

Header: The name displayed in the control Header.

    Main events:Toggled: The Processing Event is triggered when the status is switched.

    Xaml and Cs code:

        <ToggleSwitch  HorizontalAlignment="Left" Margin="471,317,0,0"                       OffContent="Open" OnContent="Close" Header="Music"                      VerticalAlignment="Top" Width="175" Toggled="ToggleSwitch_Toggled_1"/>
Private void ToggleSwitch_Toggled_1 (object sender, RoutedEventArgs e) {// checks the ToggleSwitch switch Switch Status and processes var toggle = sender as ToggleSwitch; if (toggle. isOn) {this. slider1.Visibility = Visibility. visible; this. slider1.Value = 15;} else {this. slider1.Visibility = Visibility. collapsed ;}}

Finally, let's see the program running effect. If you need the source code, click Win8Slider1.rar to download it.

650) this. width = 650; "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1A54BJ7-0.jpg "data-mce-src =" http://www.bkjia.com/uploads/allimg/131228/1A54BJ7-0.jpg "/>

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.