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.