如何调用我的函数C#以使我的代码XAML中的按钮闪烁

时间:2018-07-01 21:22:19

标签: c# wpf xaml

当我的代码为!=0的变量时,我试图使按钮闪烁。

XAML:

<cc:ImageButton  Name="Sollicitations" IsEnabled="{Binding Path=DataChanged}" Content="Sollicitations" ImgSource="..\..\Images\ActionBar\icon_sollicitation.png"  >
    <Button.Style>
        <Style TargetType="Button">
            <Style.Triggers>
                <DataTrigger Binding="{Binding DataChanged}" Value="true">
                    <DataTrigger.EnterActions>
                        <BeginStoryboard x:Name="sb1">
                            <BeginStoryboard.Storyboard>
                                <Storyboard AutoReverse="True" RepeatBehavior="Forever">
                                    <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" >
                                        <EasingColorKeyFrame KeyTime="0" Value="Red"/>
                                        <EasingColorKeyFrame KeyTime="0:0:1" Value="#FF0004FF">
                                            <EasingColorKeyFrame.EasingFunction>
                                                <QuinticEase EasingMode="EaseInOut"/>
                                            </EasingColorKeyFrame.EasingFunction>
                                        </EasingColorKeyFrame>
                                    </ColorAnimationUsingKeyFrames>
                                </Storyboard>
                            </BeginStoryboard.Storyboard>
                        </BeginStoryboard>
                    </DataTrigger.EnterActions>
                    <DataTrigger.ExitActions>
                        <StopStoryboard BeginStoryboardName="sb1"/>
                    </DataTrigger.ExitActions>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </Button.Style>
</cc:ImageButton>

后面的代码:

public bool _DataChanged = false;
public bool Datachanged
{
    get
    {
        return _DataChanged;
    }
    set
    {
        if (_DataChanged != value && gintSollic != 0)
        {
            _DataChanged = value;
            RaisePropertyChanged("Datachanged");
        }
    }
}


void RaisePropertyChanged(string prop)
{
    if (PropertyChanged != null)
    { 
        PropertyChanged(this, new PropertyChangedEventArgs(prop)); 
    }
}

public event PropertyChangedEventHandler PropertyChanged;

0 个答案:

没有答案