在边框对象上设置 Panel.Background? [英] Setting Panel.Background on a Border object?

查看:52
本文介绍了在边框对象上设置 Panel.Background?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白微软的这个按钮模板示例是如何工作......在其各种状态的故事板中,它正在为边框的目标类型设置Panel.Background(下面的示例).我没有看到 Border 以任何方式从 Panel 继承.

I am not understanding how this Button Template Example from Microsoft is working... In its storyboards for its various states, it is setting Panel.Background for a target type of Border (example below). I don't see that Border inherits from Panel in any way.

将 TargetProperty 设置为 Border.Background... 似乎以同样的方式工作.我只想了解正在发生的事情的细微差别......每次我认为我可以处理WPF,我遇到了无法解释的事情:(

Setting the TargetProperty to Border.Background... seems to work the same way. I would just like to understand the nuances of what is going on... Every time I think I have a handle on WPF, I run into something I can't explain :(

<ColorAnimationUsingKeyFrames
    Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)"
    Storyboard.TargetName="Border">
    <EasingColorKeyFrame
        KeyTime="0"
        Value="{StaticResource ControlPressedColor}" />

推荐答案

那是因为依赖属性可以重用,Border只是通过添加Panel的属性AddOwner.属性字段初始化如下:

That is because dependency properties can be reused, the Border just adds the property of the Panel via AddOwner. The property field is initialized like this:

public static readonly DependencyProperty BackgroundProperty =
         Panel.BackgroundProperty.AddOwner(typeof(Border), ...

所以 Panel.Background 属性与 Border.Background 属性相同.

So the Panel.Background property is the same as the Border.Background property.

这篇关于在边框对象上设置 Panel.Background?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆