Fix for Button control
On forum, there was thread about button control affecting cursor behavior even when cursor is out of button and on the right. Here is the fix for it… It seems in the update layout method, one of the rectangles ( outlineHighlight) that constitute visuals for the button is not updated.
<Rectangle x:Name="outlineHighlight" Width='115' Height='20' RadiusX="10" RadiusY="10" Opacity="0">
This means there is a part of button hanging outside visual boundary of the button and that capture the mouseover behavior. Fix is pretty straight forward because all you have to do is update that rectangle when button height and width changes.
Member Variable
In the Button.cs file for button class you need to add member variable for the rectangle.
public class Button : ButtonBase { Rectangle outlinehighlight;
Get a Reference to the Rectangle
Find that Rectangle in the button constructor using FindName API
public Button() { text = (TextBlock)FindName("text"); dimlight = FindName("dimlight") as Rectangle; outline = FindName("outline") as Rectangle; highlight = FindName("highlight") as Rectangle; outlinehighlight = FindName("outlineHighlight") as Rectangle; }
UPdate Updatelayout method
Update the rectangle height and width etc in UpdateLayout method for the button class.
if (outline != null) { outline.Width = Width; outline.Height = Height; outline.RadiusX = outline.RadiusY = Height / 2; outlinehighlight.Height = Height; outlinehighlight.Width = Width; outlinehighlight.RadiusX = outline.RadiusX; }
[...] http://vivekdalvi.wordpress.com/2007/05/18/fix-for-button-control/ Posted: Friday, May 18, 2007 9:00 PM by vivekd Filed under: Silverlight [...]
Recursive Reflection : Fix for Button Control
May 18, 2007 at 8:00 pm
Interesting stuff mate.
Denise Vandermoon
June 4, 2011 at 4:24 am
I do consider all the ideas you have presented to your post. They’re really convincing and will certainly work. Nonetheless, the posts are very brief for beginners. May you please lengthen them a little from next time? Thank you for the post.
cloud hosting
December 2, 2011 at 1:32 am