我有与情节提要的网格,如下所示。

<Grid x:Name="grd_Order"   Grid.Column="2" Height="16" Margin="0,-2,0,0" Visibility="Collapsed" HorizontalAlignment="Center" VerticalAlignment="Center">
  <Grid.Resources>
    <Storyboard x:Key="stry_OrderMsgShowHide"  RepeatBehavior="3x">
     <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Visibility)" >
       <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
       <DiscreteObjectKeyFrame KeyTime="0:0:2" Value="{x:Static Visibility.Collapsed}"/>
     </ObjectAnimationUsingKeyFrames>
   </Storyboard>
  </Grid.Resources>
<Grid.Style>
 <Style >
   <Style.Triggers>
     <DataTrigger Value="True" Binding="{Binding Path=BlinkOrderAlert,Mode=TwoWay}">
       <DataTrigger.EnterActions>
        <BeginStoryboard x:Name="stry_BlinkOrdAlert" Storyboard="{StaticResource stry_OrderMsgShowHide}"/>
       </DataTrigger.EnterActions>
     </DataTrigger>
  </Style.Triggers>
</Style>




在我的ViewModel.cs中

        private bool blinkOrderAlert;
        public bool BlinkOrderAlert
        {
            get
            {
                return blinkOrderAlert;
            }
            set
            {
                if (blinkOrderAlert == value)
                    return;
                this.blinkOrderAlert = value;
                this.RaisePropertyChanged(this, new PropertyChangedEventArgs("BlinkOrderAlert"));
            }
        }

        public void BlinkOrdAlert()
        {
                this.BlinkOrderAlert=false;
                this.BlinkOrderAlert = true;

        }
public ViewModel()
{
  this.BlinkOrderAlert=true;
}


并且仅在构造函数初始化时才第一次起作用。每当我调用BlinkOrdAlert函数时,它就不再起作用。每次调用函数时,如何修改数据触发器以运行情节提要?谢谢。

最佳答案

考虑将以下数据触发器添加到样式中。
当BlinkOrderAlert值设置为false时,Following数据触发器将删除故事板,当该值为true时,它将添加故事板。

希望这会有所帮助。

<DataTrigger Value="False" Binding="{Binding Path=BlinkOrderAlert,Mode=TwoWay}">
                    <DataTrigger.EnterActions>
                        <RemoveStoryboard BeginStoryboardName="stry_BlinkOrdAlert"></RemoveStoryboard>
                    </DataTrigger.EnterActions>
                </DataTrigger>

10-07 15:12