Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <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" />
- 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();
- }
- <Style TargetType="ToggleButton" x:Key="FlipButton">
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="ToggleButton">
- <Grid>
- <VisualStateManager.VisualStateGroups>
- <VisualStateGroup x:Name="CheckStates">
- <VisualState x:Name="Checked">
- <Storyboard>
- <DoubleAnimation Duration="0" Storyboard.TargetName="rotate" Storyboard.TargetProperty="(RotateTransform.Angle)" To="180" />
- </Storyboard>
- </VisualState>
- <VisualState x:Name="Unchecked">
- <Storyboard>
- <DoubleAnimation Duration="0" Storyboard.TargetName="rotate" Storyboard.TargetProperty="(RotateTransform.Angle)" To="0" />
- </Storyboard>
- </VisualState>
- </VisualStateGroup>
- </VisualStateManager.VisualStateGroups>
- <ContentPresenter Content="{TemplateBinding Content}">
- <ContentPresenter.RenderTransform>
- <RotateTransform x:Name="rotate" CenterX="0.5" CenterY="0.5" />
- </ContentPresenter.RenderTransform>
- </ContentPresenter>
- </Grid>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- <ToggleButton x:Name="MyToggleButton" Style="{StaticResource FlipButton}">
- <ToggleButton.Content>
- <Image Source="/Images/appbar.arrow.down.circle.rest.png" />
- </ToggleButton.Content>
- </ToggleButton>
- <TextBlock Text="Hello world" Visibility="{Binding ElementName=MyToggleButton,Path=IsChecked,Converter={StaticResource ValueConverterBoolToVis}}" />
- public class ValueConverterBoolToVis : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- return ((bool)value) ? Visibility.Visible : Visibility.Collapsed;
- }
- public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- <local:ValueConverterBoolToVis x:Key="local:ValueConverterBoolToVis" />
Add Comment
Please, Sign In to add comment