Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

XAML Trigger or Condition Within Another Trigger

$
0
0

This seems like a strange request, I know.  Why not just use MultiDataTrigger?  Here is the problem:

My custom UserControl, based on a CheckBox has a style which makes it look like a wheel (actually more like an octagon), with spokes.  Top of the octagon is yellow, while everything else is black, so we can see "where it is" in the rotation. 

When the checkbox is checked, a RotateTransform executes "forever", and the wheel spins, about 2 seconds per rotation.  This is done via a MultiDataTrigger causing a storyboard to run in its EnterActions.  

When the checkbox is unchecked, it rotates back to the 0 degrees position.  This is done by stopping the storyboard and running another storyboard which sets the angle to 0 degrees over about 1/4 second.  This is done in the ExitActions of the same MultiDataTrigger.

Here's the issue:  If the rotation is near the beginning (<90 degrees) the wheel jumps back to 0 degrees at a reasonable speed (1/4 second).  If it is farther along (say 270 degrees) in its rotation, it jumps back to 0 degrees VERY fast (over the same 1/4 second).  

I can tell the "End Rotation" storyboard to return it to 360 degrees instead of 0, so it doesn't appear to be jumping backwards, but then the same issue occurs if I stop it at only 10 degrees of rotation:  It jumps all the way around to 360 degrees VERY fast.

So, my thought is to figure out the current angle somehow during the exit actions, or when the checkbox is unchecked.  If the angle is less than 90 degrees, return to 0 degrees.  If the angle is more than 90 degrees, send it to 360 degrees.  This would minimize the fast jumping, I think.

So, that is my question.  Is there any way to sense the current angle in the context of the exit actions of the multidata trigger?

Thanks...


Ron Mittelman


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>