【问题标题】:Is it possible to set the MaxWidth of a control using VisualStateManager是否可以使用 VisualStateManager 设置控件的 MaxWidth
【发布时间】:2013-10-01 08:08:31
【问题描述】:

是否可以在 xaml 中使用 VisualStateManager 设置控件的最大宽度? 当我尝试设置控件的最大宽度时,在混合中出现以下异常:

ArgumentException:属性 MaxWidth 的属性值无效。

xaml 是

<DoubleAnimation Duration="0" To="1000" Storyboard.TargetProperty="(FrameworkElement.MaxWidth)" Storyboard.TargetName="AbcControl" d:IsOptimized="True"/>

【问题讨论】:

  • 您是否在某处设置了动画的起始值,或者通过在开始动画之前设置AbcControl.MaxWidth,或者通过设置动画的From 属性?
  • 不,我没有。如果您可以删除一行描述此内容的 xaml,那将非常有帮助。
  • @Clemens 从你的回复中得到了一些线索.. 以下几行使它起作用.. 虽然我不得不手动编写这些行而不是自动混合生成它们
  • @MakeItPerfect,请将您的解决方案添加到答案中,并尽可能将其标记为正确答案?

标签: c# wpf silverlight xaml visualstatemanager


【解决方案1】:

遵循 xaml 使其工作.. 虽然我必须手动编写这些行而不是自动混合生成它们

<ObjectAnimationUsingKeyFrames Storyboard.TargetName="AbcControl" Storyboard.TargetProperty="(FrameworkElement.MaxWidth)"> <DiscreteObjectKeyFrame KeyTime="0" Value="1000" /> </ObjectAnimationUsingKeyFrames>

【讨论】:

    猜你喜欢
    • 2015-08-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-16
    • 1970-01-01
    相关资源
    最近更新 更多