Binding ElementName
Posted
by zvi
on Stack Overflow
See other posts from Stack Overflow
or by zvi
Published on 2010-04-26T15:54:30Z
Indexed on
2010/04/27
7:33 UTC
Read the original article
Hit count: 433
wpf
|elementname
Hello First Sorry for my English. I wanted to ask why ElementName does not work the first case, and work in the second.
I give the two sections of code . the firts not work
<Button
Name="button1" Width="100" >
<Button.LayoutTransform>
<ScaleTransform x:Name="ttt" ScaleX="3" ScaleY="6"/>
</Button.LayoutTransform>
<Button.Triggers>
<EventTrigger RoutedEvent="Path.Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard RepeatBehavior="Forever">
<DoubleAnimation
Storyboard.Target="{Binding ElementName=ttt}"
Storyboard.TargetProperty="ScaleX"
From="10"
To="5"
Duration="0:0:1"
/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Button.Triggers>
Button
</Button>
But it does work
<Button
Name="button1" Width="100" >
<Button.LayoutTransform>
<ScaleTransform x:Name="ttt" ScaleX="3" ScaleY="6"/>
</Button.LayoutTransform>
<Button.Triggers>
<EventTrigger RoutedEvent="Path.Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard RepeatBehavior="Forever">
<DoubleAnimation
Storyboard.Target="{Binding ElementName=button1}"
Storyboard.TargetProperty="Width"
From="100"
To="50"
Duration="0:0:1"
/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Button.Triggers>
Button
</Button>
I know I can use Storyboard.TargetName .
© Stack Overflow or respective owner