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 "/>