<Slider Height="23" HorizontalAlignment="Left" Margin="8,19,0,0" Name="slider1" VerticalAlignment="Top" Width="100" Maximum="10" Minimum="0" Value="5" /> <Slider Height="90" HorizontalAlignment="Left" Margin="128,52,0,0" Name="slider2" VerticalAlignment="Top" Width="100" Minimum="0" Maximum="10" Orientation="Vertical" Value="3" IsDirectionReversed="True" />
2,Name, Height, Width,
Maxmum, Minmum, Value,
Orientation[布局方向]=[水平方向|垂直方向], IsDirectionReversed[增长方向]=[True[自右向左增加|自上而下增加]]
3,//赋值 this.slider1.Value = 10; this.slider1.Orientation = Orientation.Horizontal; //水平方向 this.slider1.IsDirectionReversed = true; //自右而左递增 //取值 double var = this.slider1.Value;
4,
1.B,返回顶部 Slider控件(滑动器控件)之ValueChanged事件 1,<Slider Height="23" HorizontalAlignment="Left" Margin="138,185,0,0" Name="slider3" VerticalAlignment="Top" Width="100" ValueChanged="slider3_ValueChanged" /> <dataInput:Label Height="15" HorizontalAlignment="Left" Margin="138,232,0,0" Name="label1" VerticalAlignment="Top" Width="100" />
2,文字同上 1.A.3
3,ValueChanged 事件public Slider() { InitializeComponent(); //赋值 this.slider3.Value = 3; //设置默认值 } /// <summary> /// 值已改变事件 /// 【注意: slider3控件前台的 value不要设默认值,否则回引发异常,但可以在后台设值】 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void slider3_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) { //方式一 //this.label1.Content = this.slider3.Value.ToString(); //这种方式也可以,但不建议使用 //方式二 double newValue = e.NewValue; //新值 double oldValue = e.OldValue; //旧值 this.label1.Content = e.NewValue.ToString(); //建议使用这种方式 }
4,
作者:ylbtech