我遵循这教程如何在VS混合中创建Windows /7样式的玻璃按钮(我正在使用VS 2013 Community )。当谈到按钮的发光,我想重新创建Windows 7如何处理任务栏上的按钮-就像鼠标在按钮上方时,光线本身的径向梯度总是以光标为中心。
我的猜测是,我希望将梯度(x和y)的位置绑定到光标坐标。
在混合中,我如何将径向梯度的坐标绑定到鼠标光标的x/y坐标?
发布于 2015-04-02 08:29:29
一种方法是将依赖项属性添加到视图中,并将其挂钩到MouseMove事件。
依赖项属性:
public static readonly DependencyProperty MousePointProperty = DependencyProperty.Register(
"MousePoint",
typeof (Point),
typeof (MyWindow),
new FrameworkPropertyMetadata(new Point());
public Point MousePoint
{
get { return (Point)GetValue(MousePointProperty ); }
set { SetValue(MousePointProperty , value); }
}然后在MouseMove处理程序中,更新这一点。在XAML中(这是在一个矩形上,应该类似于您的控件):
<Rectangle>
<Rectangle.Fill>
<RadialGradientBrush GradientOrigin="{Binding MousePoint}"/>
</Rectangle.Fill>
</Rectangle>https://stackoverflow.com/questions/29407272
复制相似问题