I am rotating the arrow image from down to up which is working ok when the user first taps it.
But my question is how to reverse from down to up on second tap and so on…
Below is my XAML image which is inside a longlistselector control
<Image Grid.Column="2" Tap="ArrowDownImg_Tap" x:Name="ArrowDownImg" Margin="0,-10,-33,0" Height="40" Width="40" Source="/Images/appbar.arrow.down.circle.rest.png" />
The tap code to rotate the image
private void ArrowDownImg_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
Duration duration = new Duration(TimeSpan.FromMilliseconds(500));
Storyboard sb = new Storyboard();
sb.Duration = duration;
DoubleAnimation da = new DoubleAnimation();
da.Duration = duration;
sb.Children.Add(da);
RotateTransform rt = new RotateTransform();
Storyboard.SetTarget(da, rt);
Storyboard.SetTargetProperty(da, new PropertyPath("Angle"));
da.To = 180;
ImageShowHide.RenderTransform = rt;
ImageShowHide.RenderTransformOrigin = new Point(0.5, 0.5);
sb.Begin();
}
The best way to do this IMO is to use a style. And really, this seems like a toggle button more than an image. You can work from the default control template.
Place the style in your resources section, then you can reference it from a Toggle Button.
Now, also, you don’t need the click handler, just bind the text box visibility directly to the toggle button.
There are lots of resources on using Control Templates and Visual States, here’s a good one on MSDN.
Edit
Here’s the code for the IValueConverter.
Add it to the resources using