WP8中的PropertyChangedTrigger不工作
本文关键字:工作 PropertyChangedTrigger 中的 WP8 | 更新日期: 2023-09-27 18:07:59
我需要创建一个百分比加载器控件。我创建了一个双弧控件。一个弧用于背景,一个弧用于前景。我将给出端点角作为弧的输入。我写了一个双动画类来执行加载动画。当我试图在代码中调用故事板时,动画工作了。
但是我的要求是,每当属性改变时,我需要加载加载器。所以我决定使用PropertyChangedBehaviour。但动画并不奏效。请建议最好的方法来做这件事
下面是xaml代码:
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="ValueStates">
<VisualState x:Name="On">
<Storyboard x:Name="storyBoard2">
<DoubleAnimation Duration="0:0:9" To="270" Storyboard.TargetProperty="(Arc.EndAngle)" Storyboard.TargetName="TimerProgressBar">
<DoubleAnimation.EasingFunction>
<ExponentialEase EasingMode="EaseOut"/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid Grid.Row="1"
Background="Transparent"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Margin="0 40 0 0">
<i:Interaction.Triggers>
<ec:PropertyChangedTrigger Binding="{Binding EndAngleValue}">
<ec:GoToStateAction StateName="On"/>
</ec:PropertyChangedTrigger>
</i:Interaction.Triggers>
<es:Arc ArcThickness="1"
Fill="{StaticResource OlaTextLightGrayBrush}"
ArcThicknessUnit="Pixel"
Stretch="None"
Stroke="{StaticResource OlaTextLightGrayBrush}"
StartAngle="0"
EndAngle="360"
UseLayoutRounding="False"
Width="297"
Height="297" />
<es:Arc ArcThickness="4"
Fill="{StaticResource OlaGreenBrush}"
x:Name="TimerProgressBar"
ArcThicknessUnit="Pixel"
Stretch="None"
StartAngle="0"
UseLayoutRounding="False"
Width="300"
Height="300" VerticalAlignment="Bottom" d:LayoutOverrides="Height" >
<es:Arc.Stroke>
<SolidColorBrush
Color="{StaticResource OlaGreen}"/>
</es:Arc.Stroke>
</es:Arc>
My View Model:
public double EndAngleValue
{
get
{
return _EndAngleValue;
}
set
{
SetProperty(ref _EndAngleValue, value);
}
}
当属性'危害值'改变时,我需要执行动画。
欢迎提出建议
如果你已经实现了,那么你应该能够这样做:
public double EndAngleValue
{
get
{
return _EndAngleValue;
}
set
{
SetProperty(ref _EndAngleValue, value);
OnPropertyChanged("EndAngleValue");
}
}
private OnPropertyChanged(string propertyName)
{
if(PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}