Tuesday, March 8, 2011

Creating Borders in Silverlight

So this might seem simple enough but I was asked a couple times recently so I thought I would put a post out there on topic, ok so its more of a half tweet half blog post as its pretty simple but here is how to create a 'border' in silverlight without some hack on a rectangle or some sillyness.

<border borderthickness="20" background="white" borderbrush="Green" padding="3" cornerradius="10" >
<textblock text="Hello World" />
</textblock>
<border/>

So here you can see that you have some basic properties you can sent, like color, padding, thickness but intellisence in visual studio will tell you all you need to know. and thats it, that is how to create a use a 'border' in XAML in Silverlight.

3 comments:

  1. It is worth pointing out that any class that inherits from Control will also have BorderThickness, BorderBrush and CornerRadius and thus should have a Border within its Template. Therefore, you only need to set these properties in order to render a border (as long as the person who designed the control subclass has bothered to wire up these properties!)

    Regards, Colin E.

    ReplyDelete
  2. yes, true :) but I guess the question was about creating a discreet border so I just posted this sample as the way to do it.

    ReplyDelete
  3. This is a nice article..
    Its very easy to understand ..
    And this article is using to learn something about it..
    asp.net, c#, javascript
    Thanks a lot..!

    ReplyDelete