English 中文(简体)
使用 wpf 中的变换组给出错误
原标题:using transformgroup in wpf gives an error
  • 时间:2012-05-23 06:16:19
  •  标签:
  • wpf

i 正在查找一个对象中的多个变换组合,我发现,当我尝试设置 < strong > Transformgroup 时, 问题是如何解决, 它会出错误 < strong >, “ 无法解决属性路径 RenderTransform. SASALX. 验证适用对象是否支持这些属性。

这是我从网络上复制的变换代码 (“感谢制定这个代码的人 ” ) 。

    <Window.Resources>
    <Storyboard x:Key="expandStoryboard">
        <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleX" 
    To="1.3" Duration="0:0:0.2" />
        <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleY"
    To="1.3" Duration="0:0:0.2" />
    </Storyboard>
    <Storyboard x:Key="shrinkStoryboard">
        <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleX"
    To="1" Duration="0:0:0.2" />
        <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleY"
    To="1" Duration="0:0:0.2" />
    </Storyboard>
    <Storyboard x:Key="shakeStoryBoard">
        <DoubleAnimation Storyboard.TargetProperty="RenderTransform.Angle"
                            From="-5" To="5" Duration="0:0:0.05" 
                            AutoReverse="True"
                            RepeatBehavior="3x"
                            FillBehavior="Stop" />
    </Storyboard>

这就是我的归宿。

        <Button RenderTransformOrigin="0.5,0.5" Background="Transparent" Focusable="False"  BorderBrush="Transparent"  Height="220" HorizontalAlignment="Left" Margin="591,213,0,0" Name="cmdsettings" VerticalAlignment="Top" Width="189">
        <StackPanel Orientation="Vertical" HorizontalAlignment="Center"  VerticalAlignment="Center" Width="217" Height="220">
            <Image HorizontalAlignment="Center" VerticalAlignment="Center"   Source="Images/settings.png" Height="192" Width="204" />
            <TextBlock VerticalAlignment="center" TextAlignment="center" FontSize="16" Width="123" Foreground="white" FontWeight="Bold" Height="20">Settings</TextBlock>
        </StackPanel>
        <Button.Triggers>
            <EventTrigger RoutedEvent="Button.MouseEnter">
                <BeginStoryboard Storyboard="{StaticResource expandStoryboard}" />
            </EventTrigger>
            <EventTrigger RoutedEvent="Button.MouseLeave">
                <BeginStoryboard Storyboard="{StaticResource shrinkStoryboard}" />
            </EventTrigger>
            <EventTrigger RoutedEvent="Button.Click">
                <BeginStoryboard Storyboard="{StaticResource shakeStoryBoard}" />
            </EventTrigger>
        </Button.Triggers>
        <Button.RenderTransform >
            <TransformGroup>
                <ScaleTransform ScaleX="1" ScaleY="1"/>
                <RotateTransform />
            </TransformGroup>                    
        </Button.RenderTransform>
    </Button>
最佳回答

由于 button. render Transform 包含一个变换组, 您需要通过 < a href=> http://msdn. microsoft. com/ en- us/library/ system. windows. media. transformgroup. children. aspx" rel = "nofollow" 来访问包含的变换组 。

<DoubleAnimation Storyboard.TargetProperty="RenderTransform.Children[0].ScaleX" ... />  
<DoubleAnimation Storyboard.TargetProperty="RenderTransform.Children[0].ScaleY" ... />
<DoubleAnimation Storyboard.TargetProperty="RenderTransform.Children[1].Angle" ... />
问题回答

暂无回答




相关问题
WPF convert 2d mouse click into 3d space

I have several geometry meshes in my Viewport3D, these have bounds of (w:1800, h:500, d:25). When a user clicks in the middle of the mesh, I want the Point3D of (900, 500, 25)... How can I achieve ...

Editing a xaml icons or images

Is it possible to edit a xaml icons or images in the expression design or using other tools? Is it possible to import a xaml images (that e.g you have exported) in the expression designer for editing?...

WPF: writing smoke tests using ViewModels

I am considering to write smoke tests for our WPF application. The question that I am faced is: should we use UI automation( or some other technology that creates a UI script), or is it good enough to ...

WPF - MVVM - NHibernate Validation

Im facing a bit of an issue when trying to validate a decimal property on domain object which is bound to a textbox on the view through the viewmodel. I am using NHibernate to decorate my property on ...

How do WPF Markup Extensions raise compile errors?

Certain markup extensions raise compile errors. For example StaticExtension (x:Static) raises a compile error if the referenced class cannot be found. Anyone know the mechanism for this? Is it baked ...

WPF design-time context menu

I am trying to create a custom wpf control, I m wondering how I can add some design-time features. I ve googled and can t seem to get to my goal. So here s my simple question, how can I add an entry ...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签