【问题标题】:Change ImageSource during Storyboard in code behind在后面的代码中更改情节提要期间的 ImageSource
【发布时间】:2012-03-22 21:58:12
【问题描述】:

我需要创建一个故事板,在其中更改图像控件的 ImageSource 以使其更流畅,但我不知道如何执行此操作,因为我是故事板的新手。

有人可以解释一下如何做到这一点吗?

这是我的 XAML: (CenterScaleImage 只是一个带有 2 个额外属性的 Image-ctrl)

<Grid x:Name="LayoutRoot" DataContext="{Binding Main, Mode=OneWay, Source={StaticResource Locator}}" Background="White">
        <Controls:CenterScaleImage x:Name="Image" Margin="0" Source="{Binding PropVisibleImage}" ScaleFactor="{Binding PropScaleFactor}" CenterScaleX="{Binding PropScaleCenterX}" CenterScaleY="{Binding PropScaleCenterY}">
            <Controls:CenterScaleImage.RenderTransform>
                <TransformGroup>
                    <ScaleTransform ScaleY="{Binding PropScaleFactor}" ScaleX="{Binding PropScaleFactor}" CenterX="{Binding PropScaleCenterX}" CenterY="{Binding PropScaleCenterY}"/>
                    <SkewTransform/>
                    <RotateTransform/>
                    <TranslateTransform X="{Binding PropPanHorizontal}" Y="{Binding PropPanVertical}"/>
                </TransformGroup>
            </Controls:CenterScaleImage.RenderTransform>
        </Controls:CenterScaleImage>
    </Grid>

【问题讨论】:

  • 从 MSDN 阅读 this guide
  • @milter thx 但我需要在代码隐藏中进行。

标签: c# wpf image xaml storyboard


【解决方案1】:

您不能将图像源更改为情节提要的一部分。故事板动画要求在动画过渡(补间)中的一个状态和下一个状态之间可以计算插值 - 在这种情况下交换图像没有意义。 ~最好的办法是创建一个数据或属性触发器来交换图像源,如果这是你需要的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-11-17
    • 2015-07-17
    • 2018-09-24
    • 2010-12-20
    • 2013-11-14
    • 1970-01-01
    • 1970-01-01
    • 2015-05-05
    相关资源
    最近更新 更多