我在 wpf 中有一个滑块,希望用户设置它的最小值和最大值。
在xml代码中:
<Slider x:Name="slider1" Width="34" Minimum="{Binding Path=Minval}" Value="10" Height="105" Margin="5,5,5,5" Maximum="{Binding Path=Maxval}"/>
<TextBox Height="23" HorizontalAlignment="Left" Margin="5,5,5,5" Name="minvaltxt" VerticalAlignment="Top" Width="120" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="5,5,5,5" Name="maxvaltxt" VerticalAlignment="Top" Width="120" />
<Button Content="Apply" Name="btn" Height="23" HorizontalAlignment="Left" Margin="5,5,5,5" VerticalAlignment="Top" Width="24" Click="btn_Click" />
在后面的代码中:
private double maxval = 80;
public double Maxval
{
get { return maxval; }
set { value = maxval; }
}
private double minval = 5;
public double Minval
{
get { return minval; }
set { value = minval; }
}
private void btn_Click(object sender, RoutedEventArgs e)
{
minval= double.Parse(minvaltxt.Text);
maxval= double.Parse(maxvaltxt.Text);
slider1.Minimum = Minval
slider1.Maximum = Maxval;
}
但它不会更新 silder 的最小值和最大值!问题是什么 ?谢谢你的帮助。
. 现在编辑的问题。谢谢。