Recommended

Skip Navigation LinksHome / Tips / View Tip

Tip: How to add an oval clip to a control

+ Add to SilverlightShow Favorites
1 comments   /   posted by Martin Mihaylov on Sep 05, 2008
(0 votes)
Tags: Silverlight , clip
Categories: General , Controls and UI

If you want to add an oval clip to your control, you can do it the following way:

Xaml

<Button x:Name="MyButton" Content="Click me!" Width="80" Height="30">
    <Button.Clip>
        <EllipseGeometry RadiusX="35" RadiusY="13" Center="40,15"></EllipseGeometry>
    </Button.Clip>
</Button>

C#

EllipseGeometry myClip = new EllipseGeometry();
myClip.Center = new Point( MyButton.Width / 2, MyButton.Height / 2 );
myClip.RadiusX = MyButton.Width / 2;
myClip.RadiusY = MyButton.Height / 2;
 
MyButton.Clip = myClip;

For the example we use a button. We set the clip using the System.Windows.Media.EllipseGeometry object. The center is in relation to the size of the button. In this case we have a button with height 30 and width 80. The center of the button will be with coordinates (40,15). We set the center of the clip to the center of the rectangle. Of course we can set it anywhere we want. We use the RadiusX and RadiusY properties to define the size.

Without clip

With clip

That's it!

Share


Comments

Comments RSS RSS
  • RE: Tip: How to add an oval clip to a control  

    posted by coco on Oct 28, 2009 09:17
    If you've been using Google's wedding invitations AdSense on your website you obviously feel wedding invitation the need to somehow generate even more traffic bridesmaid dresses for your website, which successively would translate to more bridesmaids dresses AdSense clicksmouse clicks and a higher income. But how do you achieve this?

Add Comment

 
 

   
  
  
   
Please add 3 and 6 and type the answer here:

Help us make SilverlightShow even better and win a free t-shirt. Whether you'd like to suggest a change in the structure, content organization, section layout or any other aspect of SilverlightShow appearance - we'd love to hear from you! Need a material (article, tutorial, or other) on a specific topic? Let us know and SilverlightShow content authors will work to have that prepared for you. (hide this)