0

I try to display a button that shows some text. Every X seconds the button must slide to the left and reappear with a new text inside.

Due to the other object on my page I can't use a popup.

Any ideas on how to do this ?

I already try with a grid, except that I don't find how to slide it.

XAML

   <Grid  x:Name="PropoCloud" VerticalAlignment="Bottom">
        <tut:TutorialAwareButton Name="PropoButton"
                                         Style="{StaticResource tplButtonCloud}"
                                         Command="{Binding CmdCreated}"
                                         BorderThickness="0" VerticalAlignment="Bottom" 
                                         HorizontalAlignment="Left" Width="410" Height="200">
            <tut:TutorialAwareButton.CommandParameter>
                <cmd:NavigationCommandParameter TargetName="QuestionCreatingView"></cmd:NavigationCommandParameter>
            </tut:TutorialAwareButton.CommandParameter>
        </tut:TutorialAwareButton>
    </Grid>

C#

private void SuggestionCycling()
{
    if (PropoCloud.Visibility == Visibility.Visible)
    {
        PropoCloud.Visibility = Visibility.Collapsed;
    }
    else
    {
        PropoCloud.Visibility = Visibility.Visible;
    }
}
Adrien Blaizot
  • 47
  • 1
  • 2
  • 11

1 Answers1

0

Code that you have posted will only hide and show the control back again, you need to have animation to fly it out and bring it in ... have a look at this Link to understand how animation can do that...

The provided link is not for you to copy, make changes to suit your needs and understand the concept.

This is a functionnal solution :

<VisualStateManager.VisualStateGroups>
    <VisualStateGroup x:Name="FadeStates">
        <VisualState x:Name="FadeOut">
            <Storyboard>
                <DoubleAnimation Storyboard.TargetName="PropoCloud" Storyboard.TargetProperty="PropoCloud.Opacity" From="1" To="0" Duration="0:0:1"/>
            </Storyboard>
        </VisualState>
        <VisualState x:Name="FadeIn">
            <Storyboard>
                <DoubleAnimation Storyboard.TargetName="PropoCloud" Storyboard.TargetProperty="PropoCloud.Opacity" From="0" To="1" Duration="0:0:2"/>
            </Storyboard>
        </VisualState>
    </VisualStateGroup>
</VisualStateManager.VisualStateGroups>

Just add the FadeOut.Storyboard.Begin();and FadeIn.Storyboard.Begin();In your timer cycle.

Community
  • 1
  • 1
Muds
  • 4,006
  • 5
  • 31
  • 53