我想制作Windows社区工具包的径向尺寸的动画,但是很遗憾,在RaisePropertyChanged之后,UI不会刷新自身。
这是我的代码:
查看
<TextBlock Grid.Row="0" Text="{Binding RadialGaugeValue}" />
<controls:RadialGauge
x:Name="MyRadialGauge"
Grid.Row="01"
Value="{Binding RadialGaugeValue}"
Minimum="0"
Maximum="100"
StepSize="1"
IsInteractive="False"
TickSpacing="10"
TickWidth="0"
ScaleWidth="4"
ScalePadding="29"
ScaleTickWidth="1"
MinAngle="245"
MaxAngle="115"
Unit="Sparquote"
NeedleWidth="2"
NeedleLength="100"
MaxHeight="250"
Margin="0,20,0,0"
NeedleBrush="{ThemeResource SystemColorHighlightBrush}"
FocusVisualPrimaryBrush="{x:Null}"
FocusVisualSecondaryBrush="Green"
TrailBrush="{ThemeResource SystemColorHotlightBrush}"
ValueStringFormat="."%"">
ViewModel
private async Task DoSavingRateAnimation(double myValue)
{
var progress = new Progress<int>(value =>
{
RadialGaugeValue = value;
RaisePropertyChanged("RadialGaugeValue");
});
await SavingRateAnimation(progress, myValue);
}
private Task SavingRateAnimation(IProgress<int> progress, double value)
{
return Task.Run(() =>
{
int i = 0;
while (RadialGaugeValue < value)
{
Task.Delay(100).Wait();
i += 1;
progress.Report(i);
}
});
}
如您所见,radiusGauge不会自我更新。
您是否知道如何为Control设置动画?
答案 0 :(得分:2)
请使用如下所示的双向模型设置RadialGauge
值绑定。
Value="{Binding RadialGaugeValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"