我有一个这样的滑块:滑块的值落在了其拇指的当前位置
<Slider x:Name ="slider_logo_scale" IsMoveToPointEnabled="True" Style="{StaticResource MyCustomStyleForSlider}" Grid.Row="76" Grid.Column="22" Grid.ColumnSpan="31" Grid.RowSpan="3" SmallChange="1" Value="{Binding LogoScaleValue}" Maximum="5" IsEnabled="{Binding ControlsEnabled}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="ValueChanged">
<i:InvokeCommandAction Command="{Binding SetLogoSizeCommand}" CommandParameter="{Binding Value, ElementName=slider_logo_scale}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Slider>
和视图模型:
public class ViewModel
{
public double LogoScaleValue { get; set; }
public CompositeCommand SetLogoSizeCommand { get; set; }
public ViewModel()
{
SetLogoSizeCommand = new CompositeCommand();
SetLogoSizeCommand.RegisterCommand(new DelegateCommand<Double?>(SetLogoSize));
}
private void SetLogoSize(Double? argument)
{
}
}
当我拖动滑块,一切都运行完美。但是,当我单击滑块时,拇指捕捉到正确的位置,'SetLogoSize(Double?参数)'被调用,但'参数'具有滑块大拇指的前一个值,然后跳到这个新位置。这会导致滑块返回的值落后于拇指的当前位置。
任何想法如何解决这个问题?
您是否尝试过刚刚访问'LogoScaleValue'在'SetLogoSize()'方法代替人体传递作为参数的?它绑定到滑块值,因此它应该具有最新值。 –
谢谢,这完全奏效! – Ivan