我制作了一个在mouseEnter和mouseLeave时淡入和淡出的按钮。但是我的问题是,文本或内容也在淡入和淡出..我希望它保留..还是有可能使边框淡入只出来吗?不是整个按钮?
我有这个代码:
private void Button_MouseLeave_1(object sender, MouseEventArgs e)
{
Button c = (Button)sender;
DoubleAnimation animation = new DoubleAnimation(0, TimeSpan.FromSeconds(1));
c.BeginAnimation(Button.OpacityProperty, animation);
}
private void Button_MouseEnter_1(object sender, MouseEventArgs e)
{
Button c = (Button)sender;
DoubleAnimation animation = new DoubleAnimation(1, TimeSpan.FromSeconds(1));
c.BeginAnimation(Button.OpacityProperty, animation);
}
我建议在按钮上而不是按钮内再放一个标签。将您的内容放入标签中,标签背景颜色为透明,然后在按钮上应用淡入/淡出逻辑。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句