wpf - How do I data bind the X/Y coordinates of a radial gradient to the X/Y coordinates of the mouse cursor in Blend? -
i'm following this tutorial how create windows vista/7 styled glass button in vs blend (i'm using vs 2013 community edition). when comes button shine, want re-create how windows 7 handles buttons on task bar - in, when mouse on button, radial gradient makes shine centered on cursor.
my guess make work want bind position of gradient (x , y) cursor coordinates.
how, in blend, data-bind coordinates of radial gradient x/y coordinates of mouse cursor?
one way add dependency property view, , hook mousemove event.
the dependency property:
public static readonly dependencyproperty mousepointproperty = dependencyproperty.register( "mousepoint", typeof (point), typeof (mywindow), new frameworkpropertymetadata(new point()); public point mousepoint { { return (point)getvalue(mousepointproperty ); } set { setvalue(mousepointproperty , value); } }
then in mousemove handler, update point. in xaml (this on rectangle, should similar control):
<rectangle> <rectangle.fill> <radialgradientbrush gradientorigin="{binding mousepoint}"/> </rectangle.fill> </rectangle>
Comments
Post a Comment