Skip to main content

Microsoft Silverlight

Answered Question Bug in Button sample from Silverlight.Samples.ControlsRSS Feed

(0)

StephenL
StephenL

Member

Member

14 points

12 Posts

Bug in Button sample from Silverlight.Samples.Controls

I am using the button from the sample controls in the SDK ( See http://silverlight.net/GetStarted/ ) and found that for a small button (in my case Width = 25) it incorrectly gets mouse enter events when the mouse is far to the right of the button. Besides being annoying, it causes problems for me since I have the button on top of another control that then doesnt get the events it should. To see the bug add the following two lines to the Page.xaml file of the test app included with the controls. You should see the hand cursor over the entire green rectangle except for when the mouse is directly over the button. Because of the bug you will see the arrow cursor for a big distance to the right of the button as well.

<Rectangle Canvas.Top="30" Width="150" Height="50" Fill="green" Cursor="hand"/>
<uicontrol:Button Canvas.Top="30" Canvas.Left="0" Text="1" Click="ClickHandler" Width="25"/>

I tried a few fixes on the button code but couldnt figure it out.

 Any ideas?

Thanks

Stephen

Vivek Dalvi
Vivek Dalvi

Member

Member

458 points

123 Posts

Microsoft
Answered Question

Re: Bug in Button sample from Silverlight.Samples.Controls

It seems one of the rectangle in button.xaml is not getting resized as part of UpdateLayout. I tried this changes and now it seems to work for me

Declare member variable in button.cs

Rectangle outlinehighlight;

 Add this line in constructor of button

outlinehighlight = FindName("outlineHighlight") as Rectangle;

 

Update UpdateLayout function as follows...

outlinehighlight.Height = Height;

outlinehighlight.Width = Width;

outlinehighlight.RadiusX = outline.RadiusX;

Vivek Dalvi
Program Manager
Microsoft
This post is provided "as-is"

StephenL
StephenL

Member

Member

14 points

12 Posts

Re: Bug in Button sample from Silverlight.Samples.Controls

That did fix it.

Thanks

Stephen

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities