开发者

Scale button in WPF inside ItemsControl

I created ItemsControl containg buttons. Want to make Scale clicked button. Everything was created in Blend 4 so I'm surprised that this is not working after running. Have no idea what's the problem.

    <ItemsControl Grid.Row="1" ItemsSource="{Binding Symbols}">
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <DataTemplate.Resources>
                    <Storyboard x:Key="OnClick1">
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="button">
                            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="2"/>
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="button">
                            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="2"/>
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </DataTemplate.Resources>
                <Button x:Name="button" cal:Message.Attach="[Event MouseDoubleClick] = [Action SymbolButton($dataContext)]" RenderTransformOrigin="0.5,0.5">
                    <Button.RenderTransform>
                        <TransformGroup>
                            <ScaleTransform/>
                            <SkewTransform/>
                            <RotateTransform/>
                            <TranslateTransform/>
                        </TransformGroup>
                    </Button.RenderT开发者_如何学编程ransform>
                    <Button.Template>
                        <ControlTemplate>
                            <Label FontFamily="{Binding ElementName=cbLetterTypes, Path=EditValue.Name,  Mode=OneWay}" Height="50" Width="50"  Content="{Binding Value, Mode=OneWay}" ToolTip="{Binding ToolTip}" Background="White" HorizontalAlignment="Center" VerticalAlignment="Center" BorderThickness="1" BorderBrush="Black" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"></Label>
                        </ControlTemplate>
                    </Button.Template>                        
                </Button>
                <DataTemplate.Triggers>
                    <EventTrigger RoutedEvent="ButtonBase.Click" SourceName="button">
                        <BeginStoryboard x:Name="OnClick1_BeginStoryboard" Storyboard="{StaticResource OnClick1}"/>
                        <StopStoryboard BeginStoryboardName="OnClick1_BeginStoryboard"/>
                    </EventTrigger>
                </DataTemplate.Triggers>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                    <WrapPanel/>
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
        <ItemsControl.Template>
            <ControlTemplate>
                <ScrollViewer Margin="5" VerticalScrollBarVisibility="Auto">
                    <ItemsPresenter/>
                </ScrollViewer>
            </ControlTemplate>
        </ItemsControl.Template>
    </ItemsControl>


<EventTrigger RoutedEvent="ButtonBase.Click" SourceName="button">
    <BeginStoryboard x:Name="OnClick1_BeginStoryboard" Storyboard="{StaticResource OnClick1}"/>
    <StopStoryboard BeginStoryboardName="OnClick1_BeginStoryboard"/>
</EventTrigger>

You start the storyboard and stop it right away, how is that supposed to work out?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜