我在Windows Phone app 8.1中添加了一个Slider控件
控件包含5个值。我该如何对他们采取行动?
它是通过使用c#还是XAML来实现的?
我的滑块就是这样:
<Slider Header="Imposta difficoltà" x:Name="SliderDifficolta" TickFrequency="1" StepFrequency="1" TickPlacement="Inline" Minimum="1" Maximum="5" Margin="0,190,0,251" Background="#FFD4BB18" LargeChange="10" Value="3" Foreground="#FFF8610B" SmallChange="0" />
答案 0 :(得分:0)
处理ValueChanged
事件。
首先,您需要将处理程序(ValueChanged="ValueChangedHandler"
)添加到XAML标记:
<Slider Header="Imposta difficoltà" x:Name="SliderDifficolta" TickFrequency="1" StepFrequency="1" TickPlacement="Inline" Minimum="1" Maximum="5" Margin="0,190,0,251" Background="#FFD4BB18" LargeChange="10" Value="3" Foreground="#FFF8610B" SmallChange="0" ValueChanged="ValueChangedHandler" />
然后在代码隐藏中写下事件处理程序:
private void ValueChangedHandler(object sender, RangeBaseValueChangedEventArgs e)
{
string msg = String.Format("Current value: {0}", e.NewValue);
this.textBlock1.Text = msg;
}