彩色动画内容演示器

2023-12-01

我无法在 ContentPresenter (NormalTextDay) 中创建动画或自定义颜色,此错误出现在我的 XAML 中:

“System.Windows.Media.Animation.ColorAnimation”动画对象无法用于对属性“Foreground”进行动画处理,这是因为类型“System.Windows.Media.Brush”不兼容

  <Style x:Key="CalendarDayButtonStyle" TargetType="{x:Type CalendarDayButton}">
    <Setter Property="MinWidth" Value="5"/>
    <Setter Property="MinHeight" Value="5"/>
    <Setter Property="FontSize" Value="10"/>
    <Setter Property="HorizontalContentAlignment" Value="Center"/>
    <Setter Property="VerticalContentAlignment" Value="Center"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type CalendarDayButton}">
                <Grid>
                    <VisualStateManager.VisualStateGroups>
                        <VisualStateGroup x:Name="CommonStates">
                            <VisualStateGroup.Transitions>
                                <VisualTransition GeneratedDuration="0:0:0.1"/>
                            </VisualStateGroup.Transitions>
                            <VisualState x:Name="Normal"/>
                            <VisualState x:Name="MouseOver">
                                <Storyboard>
                                    <DoubleAnimation Duration="0" To="0.5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="HighlightBackground"/>
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="Pressed">
                                <Storyboard>
                                    <DoubleAnimation Duration="0" To="0.5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="HighlightBackground"/>
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="Disabled">
                                <!--<Storyboard>
                                    <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="HighlightBackground"/>
                                    <DoubleAnimation Duration="0" To=".35" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="NormalText"/>
                                </Storyboard>-->
                            </VisualState>
                        </VisualStateGroup>
                        <VisualStateGroup x:Name="SelectionStates">
                            <VisualStateGroup.Transitions>
                                <VisualTransition GeneratedDuration="0"/>
                            </VisualStateGroup.Transitions>
                            <VisualState x:Name="Unselected"/>
                            <VisualState x:Name="Selected">
                                <Storyboard>
                                    <DoubleAnimation Duration="0" To=".75" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="SelectedBackground"/>
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                        <VisualStateGroup x:Name="CalendarButtonFocusStates">
                            <VisualStateGroup.Transitions>
                                <VisualTransition GeneratedDuration="0"/>
                            </VisualStateGroup.Transitions>
                            <VisualState x:Name="CalendarButtonFocused">
                                <Storyboard>
                                    <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Visibility" Storyboard.TargetName="DayButtonFocusVisual">
                                        <DiscreteObjectKeyFrame KeyTime="0">
                                            <DiscreteObjectKeyFrame.Value>
                                                <Visibility>Visible</Visibility>
                                            </DiscreteObjectKeyFrame.Value>
                                        </DiscreteObjectKeyFrame>
                                    </ObjectAnimationUsingKeyFrames>
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="CalendarButtonUnfocused">
                                <Storyboard>
                                    <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Visibility" Storyboard.TargetName="DayButtonFocusVisual">
                                        <DiscreteObjectKeyFrame KeyTime="0">
                                            <DiscreteObjectKeyFrame.Value>
                                                <Visibility>Collapsed</Visibility>
                                            </DiscreteObjectKeyFrame.Value>
                                        </DiscreteObjectKeyFrame>
                                    </ObjectAnimationUsingKeyFrames>
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                        <VisualStateGroup x:Name="ActiveStates">
                            <VisualStateGroup.Transitions>
                                <VisualTransition GeneratedDuration="0"/>
                            </VisualStateGroup.Transitions>
                            <VisualState x:Name="Active"/>
                            <VisualState x:Name="Inactive">
                                <Storyboard>
                                    <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="NormalTextDay"/>
                                    <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="GridValues"/>
                                    <!--<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="NormalTextDay">
                                        <EasingColorKeyFrame KeyTime="0" Value="#FFA71616"/>
                                    </ColorAnimationUsingKeyFrames>-->

                                    <!--<ColorAnimation Duration="0" To="#FF777777" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="NormalTextDay"/>-->
                                </Storyboard>

                            </VisualState>
                        </VisualStateGroup>
                        <VisualStateGroup x:Name="DayStates">
                            <VisualStateGroup.Transitions>
                                <VisualTransition GeneratedDuration="0"/>
                            </VisualStateGroup.Transitions>
                            <VisualState x:Name="RegularDay"/>
                            <VisualState x:Name="Today">
                                <Storyboard>
                                    <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="TodayBackground"/>
                                    <ColorAnimation Duration="0" To="#FFFFFFFF" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="NormalTextDay"/>
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                        <VisualStateGroup x:Name="BlackoutDayStates">
                            <VisualStateGroup.Transitions>
                                <VisualTransition GeneratedDuration="0"/>
                            </VisualStateGroup.Transitions>
                            <VisualState x:Name="NormalDay"/>
                            <VisualState x:Name="BlackoutDay">
                                <Storyboard>
                                    <DoubleAnimation Duration="0" To=".2" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Blackout"/>
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                    </VisualStateManager.VisualStateGroups>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Rectangle x:Name="TodayBackground" Fill="#FFAAAAAA" Opacity="0" RadiusY="1" RadiusX="1" Grid.RowSpan="2"/>
                    <Rectangle x:Name="SelectedBackground" Fill="#FFBADDE9" Opacity="0" RadiusY="1" RadiusX="1" Grid.RowSpan="2"/>
                    <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Grid.RowSpan="2" Background="{TemplateBinding Background}"/>
                    <Rectangle x:Name="HighlightBackground" Fill="#FFBADDE9" Opacity="0" RadiusY="1" RadiusX="1" Grid.RowSpan="2"/>
                    <ContentPresenter x:Name="NormalTextDay" TextBlock.Foreground="#FF333333" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Grid.Row="0">
                    </ContentPresenter>

                        <Path x:Name="Blackout" Data="M8.1772461,11.029181 L10.433105,11.029181 L11.700684,12.801641 L12.973633,11.029181 L15.191895,11.029181 L12.844727,13.999395 L15.21875,17.060919 L12.962891,17.060919 L11.673828,15.256231 L10.352539,17.060919 L8.1396484,17.060919 L10.519043,14.042364 z" Fill="#FF000000" HorizontalAlignment="Stretch" Margin="3" Opacity="0" RenderTransformOrigin="0.5,0.5" Stretch="Fill" VerticalAlignment="Stretch" Grid.RowSpan="2"/>
                    <Rectangle x:Name="DayButtonFocusVisual" IsHitTestVisible="false" RadiusY="1" RadiusX="1" Stroke="#FF45D6FA" Visibility="Collapsed" Grid.RowSpan="2"/>
                    <DataGrid Margin="0,0,0,0" x:Name="GridValues" Grid.Row="1">
                        <DataGrid.Columns>
                            <DataGridTemplateColumn Header="Período" Width="*" MaxWidth="200"/>
                            <DataGridTemplateColumn Header="Nº Max." Width="Auto" />
                        </DataGrid.Columns>
                    </DataGrid>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

不太确定......但你可能需要改变这一点:

Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)"

to this:

Storyboard.TargetProperty="(TextBlock.Foreground).Color"

正如在此语法中“Foreground”和“SolidColorBrush”是同一个对象,您似乎正在复制它。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

彩色动画内容演示器 的相关文章

  • 通过样式设置 DataGridCellsPresenter 的 ItemsPanel 不起作用

    我正在尝试设置ItemsPanel of a DataGridCellsPresenter在我的窗口的资源中 Bu
  • 将集合绑定到自定义控件属性

    我没有运气尝试将数据集合绑定到我的自定义控件的属性 我已经实现了该控件的字符串属性的机制 在此处提供了一些帮助 并期望集合类型同样简单 但是我无法让它再次工作 这是我的自定义控件视图
  • 数据模板绑定垃圾邮件输出窗口出现错误:找不到管理 FrameworkElemen

    我有问题 System Windows Data 错误 2 找不到目标元素的管理 FrameworkElement 或 FrameworkContentElement BindingExpression 无路径 数据项 空 目标元素是 So
  • 更改特定字符串的颜色

    有谁知道如果将特定单词输入文本区域 我如何更改它的颜色 例如 如果用户输入 你好我的朋友 它会动态地将 你好 更改为绿色 在google上花了很多时间 找不到任何相关的东西 谢谢 textareas 的设计目的不是选择性着色
  • 关闭主窗口时 WPF 应用程序不会关闭

    我习惯了在 Visual Studio 中进行 WinForms 编程 但我想尝试一下 WPF 我向我的项目添加了另一个窗口 名为 Window01 主窗口称为MainWindow 之前public MainWindow 构造函数我声明Wi
  • 如何从WPF中的另一个窗口调用方法

    我有两个窗户win1用于显示用户列表和其他win2用于添加用户 我还有一种在删除 更新或添加用户后刷新网格的方法 这个方法是在win1 我如何调用这个方法win2添加用户后 这是一个非常基本的面向对象设计问题 所以您希望能够从win2到一个
  • 转到 C# WPF 中的第一页

    我正在 WPF 中使用导航服务 为了导航到页面 我使用 this NavigationService Navigate new MyPage 为了返回我使用 this NavigationService GoBack 但是如何在不使用的情况
  • WPF/数据集:如何通过 XAML 将相关表中的数据绑定到数据网格列中?

    我正在使用 WPF DataSet 连接到 SQL Server Express XAML 和 C Visual Studio 2013 Express 我从名为 BankNoteBook 的现有 SQL Server Express 数据
  • jQuery:在动画期间禁用单击

    所以我正在做一个小测验 我想禁用里面所有内容的点击 qWrap当动画运行时 从而防止垃圾点击 我尝试使用 is animated 但没有效果 有任何想法吗 HTML div ul li class qContainer ul class q
  • 在哪里可以找到 WPF 应用程序中 UI 的一些主题/演示?

    我想使用 xaml 中的 Visual Studio Designer 设计一个现代外观的 UI 它为我提供了一个很好的工具箱 我可以使用它通过拖放来直观地创建 UI 由于它几乎表现得像 HTML 我想知道它是否也有丰富的主题库 我找到了一
  • 如何更改 OxyPlot Y 轴字符串格式?

    谁能告诉我如何更改 Y 轴字符串格式 我想向 Y 轴百分比添加百分号 我正在使用 OxyPlot 在 wpf 中生成图表 这是我的尝试 但它不起作用 Func
  • 在 WPF 中将 png 图像合并为单个图像

    我正在寻找一种将一些 PNG 平铺图像合并为大图像的方法 所以我搜索并找到了一些链接 This https stackoverflow com questions 6325057 c sharp combine lots of images
  • WPF Datagrid 循环/选择具有特定属性的单元格

    全新的 WPF 对 WinForms 非常熟悉 这可能会让过渡变得更加困难 我正在尝试将旧 WinForms 项目中的一些功能移植到 WPF 中作为学习体验 目标是在 DataGrid 中查找与 TextBox 中的字符串匹配的单元格值 我
  • 实体框架 - 绑定 WPF 树视图控件

    在服务类别表中 ParentCategoryId 是 ServiceCategoryId 它是父类别 我的类别可以有第 n 级层次结构 因此我需要使用树视图控件来呈现它 我怎样才能做到这一点 Thanks 你可以使用分层数据模板 http
  • 如何在 wpf 应用程序的代码隐藏中创建集合视图源

    我有以下代码 public partial class MainWindow Window public MainWindow InitializeComponent var entities new DemoEntities var de
  • 从固定文档中删除页面?

    如何从固定文档中删除页面 我添加这样的页面 Add page to pageContent PageContent pageContent new PageContent IAddChild pageContent AddChild fix
  • 调用线程无法访问该对象,因为另一个线程拥有它

    我已经阅读了很多关于此错误的帖子 但我不明白如何在我的解决方案中解决它 我有一个进度条对话框 其中包含一些逻辑 通过按钮单击从 MainFrame 调用 void OnBtnClick object sender RoutedEventAr
  • 在 swift3 中结合平移、alpha 和缩放动画

    我是 iOS Swift 开发的新手 我尝试将三个参数组合在一个动画中 但没有成功 我认为解决方案就在这里 Apple Dev Core 动画编程指南 https developer apple com library content do
  • JPEG 中的颜色配置文件检测

    我希望能够检测 JPEG 中是否存在颜色配置文件 需要明确的是 我对实际进行颜色校正或用它们做任何其他事情不感兴趣 我做了一些调查 但找不到任何明确的信息来源 到目前为止我所知道的是 里面有一个颜色配置信息XMP块 XMP 块位于0xFFE
  • 如何在清除排序描述后删除wpf网格排序箭头

    我单击网格标题对列进行排序 然后单击 重置 按钮以通过其集合视图清除排序描述 但排序箭头图标仍然保留在标题中 如何去除它 我在尝试弄清楚如何完全清除网格中的排序时遇到了这个问题 感谢 krishnaaditya 回答如何清除标题中的排序箭头

随机推荐