c# - Run storyboard if property mets a condition -
I have a TextBlock , which will alert a user when they save their settings to the database.
But the problem is, the animation must be run only when the database has been saved.
If the save was a success: text successfully saved with white text and fade after a few seconds.
If the save was unsuccessful: show text with no red text and do not waver
Currently I have this XML but it will always be alive:
I do not know how I can do EventTrigger conditionally any help would be appreciated!
& lt; TextBlock Text = "{Binding Message, Notification Update = True}" TextElement = "Center" Padding = "5" Grid Line = "3" grid column = "3" vertical alignment = "top" & gt; & Lt; TextBlock.Style & gt; & Lt; Style TargetType = "{x: Type Text Block}" & gt; & Lt; Setter Property = "Foreground" Value = "# FFE8E8E8" /> & Lt; Style.Triggers & gt; & Lt; Data Trigger Binding = "{Binding Hessre}" value = "true" & gt; & Lt; Setter property = "foreground" value = "red" /> & Lt; / DataTrigger & gt; & Lt; /Style.Triggers> & Lt; / Style & gt; & Lt; /TextBlock.Style> & Lt; TextBlock.Triggers & gt; & Lt; EventRegister Routing Event = "Binding. Targeted Upgraded" & gt; & Lt; BeginStoryboard & gt; & Lt; Storyboard x: name = "SB" & gt; & Lt; ObjectAnimationUsingKeyFrames Beginners = "0: 0: 0" Storyboard Target = "visibility" & gt; & Lt; DiscreteObjectKeyFrame Keytime = "0" & gt; & Lt; DiscreteObjectKeyFrame.Value & gt; & Lt; Visibility & gt; Visible & lt; / Visibility & gt; & Lt; /DiscreteObjectKeyFrame.Value> & Lt; / DiscreteObjectKeyFrame & gt; & Lt; / ObjectAnimationUsingKeyFrames & gt; & Lt; DoubleAnimation BeginTime = "0: 0: 0.0" Storyboard TargetProperty = "Opacity" from = "0" = "1" duration = "0: 0: 0" /> & Lt; DoubleAnimation BeginTime = "0: 0: 5.0" from Storyboard.TargetProperty = "Opacity" = "1" = "0" Period = "0: 0: 0.5" /> & Lt; ObjectAnimationUsingKeyFrames Beginners = "0: 0: 5.5" Storyboard Targetproperty = "visibility" & gt; & Lt; DiscreteObjectKeyFrame Keytime = "0" & gt; & Lt; DiscreteObjectKeyFrame.Value & gt; & Lt; Visibility & gt; Hide & lt; / Visibility & gt; & Lt; /DiscreteObjectKeyFrame.Value> & Lt; / DiscreteObjectKeyFrame & gt; & Lt; / ObjectAnimationUsingKeyFrames & gt; & Lt; / Storyboard & gt; & Lt; / BeginStoryboard & gt; & Lt; / EventTrigger & gt; & Lt; /TextBlock.Triggers> & Lt; / TextBlock & gt; If I had to do this in code:
if ("Message property has changed" and HasError == is wrong) Save was a successor! If Else ("Message Property Has Changed" & amp;; HasError == true) was unsuccessful!
Try using data triggers instead of an event trigger and boolean values Bind to Your visual model indicates whether save was successful or not because there is no binding in your storyboard, so the data trigger should be correct.
Comments
Post a Comment