如何对 Slider 控件的每个值进行操作?
How to act on each values of the Slider control?
我在 Windows Phone 应用程序 8.1
中添加了一个滑块控件
该控件包含 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" />
处理 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;
}
我在 Windows Phone 应用程序 8.1
中添加了一个滑块控件该控件包含 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" />
处理 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;
}