开发者

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开发者_JAVA百科 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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜