Desperately Seeking Love of Sophie

Archive for May 18th, 2007

Namescoping…

without comments

There have been many forum questions on name scoping. Ashish explains it here in his blog post.

Written by Vivek

May 18, 2007 at 8:05 pm

Posted in Professional, Software

Tagged with ,

Fix for Button control

with one comment

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;
}

Written by Vivek

May 18, 2007 at 7:55 pm

Posted in Professional, Software

Tagged with

Silverlight V1.0 Book in progress…

without comments

Laurence Moroney is working on Silverlight V1.0 book. Details are here…

http://blogs.msdn.com/webnext/archive/2007/05/18/silverlight-book.aspx

Written by Vivek

May 18, 2007 at 5:01 pm

Posted in Professional, Software

Tagged with ,