Shailesh Jaiswal
Shailesh Jaiswal

Reputation: 3654

How to remove the border of a Button in code?

I am developing a windows phone 7 application. I am new to windows phone 7 applications. In my application I have created a button control dynamically and added the background image to the button control as follows.

Button AlphabetButton = new Button();
                AlphabetButton.Content = vAlphabet;
                ImageBrush brush = new ImageBrush();
                brush.ImageSource = new BitmapImage(new Uri("button_off.png", UriKind.Relative));
                //brush.Stretch = Stretch.None;
                AlphabetButton.Background = brush;
                AlphabetButton.BorderBrush = new SolidColorBrush(Colors.Gray);

                AlphabetButton.Margin = new Thickness(-12, -27, 0, 0);
                AlphabetButton.Width = 80;
                AlphabetButton.Height = 80;     

I want to remove the border of the button control because with that border the image does not appear as per requirement. How to do this? Can we do this with the BorderThickness attribute of button control or is there any other way? Can you please provide me any code or link through which I can resolve the above issue? If I am doing anything wrong then please guide me.

Upvotes: 1

Views: 6052

Answers (2)

Thanigainathan
Thanigainathan

Reputation: 1547

I think Button.StrokeTHickness is the correct property to adjust the borders.

Upvotes: 0

Boryana Miloshevska
Boryana Miloshevska

Reputation: 2730

The easiest way is to set the BorderThickness to 0 like for Example:

            Button alphabetButton = new Button();
            alphabetButton.BorderThickness = new Thickness(0.0);

Another option could be to set the BorderBrush to Transparent or to change the whole Style of the button and especially its ControlTemplate.

Upvotes: 10

Related Questions