Exposing opacity in a custom control in Silverlight
I built a custom control, TextBoxWithButton which is composed of a TextBox and a Button near it. I want to have an Opacity property in TextBoxWithButton, that when I change it, the opacity of both TextBox and Button changes.
This is the Opacity property in TextBoxWithButton :
private double opacity = 100;
public double Opacity
{
get { return opacity; }
set
{
opacity = value;
textBox.Opacity = opacity;
button.Opacity = opacity;
}
}
But how can I make the Opacity property in TextBoxWithButton a dependency property, so I can animate it开发者_Go百科, for example.
I think you should already have Opacity property inherited in your custom control form UIElement class. It will do exactly what you are asking for.
精彩评论