【问题标题】:Exposing opacity in a custom control in Silverlight在 Silverlight 中的自定义控件中公开不透明度
【发布时间】:2011-03-14 10:41:11
【问题描述】:

我构建了一个自定义控件,TextBoxWithButton,它由一个 TextBox 和它附近的一个 Button 组成。我想在 TextBoxWithButton 中有一个 Opacity 属性,当我改变它时,TextBox 和 Button 的不透明度都会改变。

这是 TextBoxWithButton 中的 Opacity 属性:

        private double opacity = 100;
        public double Opacity
        {
            get { return opacity; }
            set
            {
                opacity = value;
                textBox.Opacity = opacity;
                button.Opacity = opacity;
            }                                       
        }

但是我怎样才能使 TextBoxWithButton 中的 Opacity 属性成为一个依赖属性,例如,我可以为它设置动画。

【问题讨论】:

    标签: silverlight custom-controls dependency-properties


    【解决方案1】:

    我认为您应该已经在自定义控件表单 UIElement 类中继承了 Opacity 属性。它会完全满足您的要求。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-10
      • 1970-01-01
      • 1970-01-01
      • 2019-04-21
      • 1970-01-01
      • 2022-01-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多