我可以在滑块中设置默认值吗? 示例我有一个介于10和100之间的范围滑块,当我在视图白色滑块上打开时,我希望有defulat 50
<Slider x:Name="TimeSlider" Minimum="0" Maximum="100" Margin="8,16,8,0"
Value="{Binding WaitingTime, Mode=TwoWay}"/>
ViewModel
private double _waitingTime = 0.1;
public double WaitingTime
{
get => _waitingTime;
set
{
_waitingTime = value;
OnPropertyChanged();
}
}
...
private void ShareCommandExecute()
{
var waitingTime = Convert.ToInt32(WaitingTime);
if(waitingTime > 0)
{
var customPinModel = new CustomPinModel
{
WaitingTime = waitingTime * 1000,
CheckinExtrasType = (int)_checkinExtrasType
};
if(_pinPosition.Latitude == default(double) && _pinPosition.Longitude == default(double))
{
GPSManagerInstance.Checkin(customPinModel);
}
else
{
GPSManagerInstance.Checkin(customPinModel, _pinPosition);
}
CloseShareLayoutCommandExecute();
}
答案 0 :(得分:0)
您的滑块的值绑定到VM WaitingTime属性。如果您希望它默认为50,则应将WaitingTime的默认值设置为50。