Bonjour,
Est-il possible, au clique sur un bouton, de lancer un storyboard puis au second clique un autre (en alternance en fait) ?
Bonjour,
Est-il possible, au clique sur un bouton, de lancer un storyboard puis au second clique un autre (en alternance en fait) ?
Euh oui.
Je vois pas trop le problème.
Code c# : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 private bool alternated; private void Button_Click(...) { Storyboard sb = null; if(alternated) sb = monStoryboard1; else sb = monStoryboard2; alternated = !alternated; sb.Begin(); }
Ouai évidenten fait Merci (mais j'ai pas eu l'email de ta réponse tiens !?)
Mais bizarrement depuis le C# je n'ai pas accès au nom de mon storyboard !?
Erreur 6 Le nom 'OnClick1' n'existe pas dans le contexte actuel
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="UntitledProject16.Window1" x:Name="Window" Title="Window1" Width="253.105" Height="271.579" > <Window.Resources> <Storyboard x:Key="OnClick1"> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.X)"> <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/> <SplineDoubleKeyFrame KeyTime="00:00:00.5" Value="-176"/> </DoubleAnimationUsingKeyFrames> </Storyboard> </Window.Resources> <Grid x:Name="LayoutRoot" Width="456" RenderTransformOrigin="0,0"> <Grid.RenderTransform> <TransformGroup> <TranslateTransform X="0" Y="0"/> </TransformGroup> </Grid.RenderTransform> <Button HorizontalAlignment="Left" Margin="180,50,0,0" VerticalAlignment="Top" Width="42" Height="26" Content="Button" x:Name="button" Click="button_Click" /> <Rectangle Margin="200,0,164,29" VerticalAlignment="Bottom" Height="61.052" Stroke="#FF000000"/> </Grid> </Window>
x:Name au lieu de x:Key dans la définition de ton Storyboard.
Mince, j'étais persuadé que c'était comme tu dis x:Name qui manquait.
Mais ça revient au même !?
J'ai pourtant rien d'autre en code que mon exemple coller plus haut![]()
Partager