Lives: 30

Constrain the Silverlight Menu

Posted Wed Nov 25, 2009 @ 8:30 AM

 

By default the Menu will attempt to position all sub-menu drop-downs inside of the Silverlight plug-in area.  Sometimes this is not the desired behaviour, in this example the Menu.Clip feature will be used to achieve a neatly aligned appearance.

 

Figure 1, the problem:

Setting a clip on the Silverlight Menu control gives you an easy way to constrain the Menu to a specific region.  A clip can contain a RectangleGeometry, in this case we are setting the clip to a rectangle starting at x,y 0,0 and extending to 480,500. Different Menu configurations will require different clip rectangles.

<ComponentArtNav:Menu x:Name="DemoMenu" Width="480" Height="32">

    <ComponentArtNav:Menu.Clip>
	<RectangleGeometry Rect="0, 0, 480, 500"/>
    </ComponentArtNav:Menu.Clip>

    <ComponentArtNav:MenuItem Text="First Item" />
    <ComponentArtNav:MenuItem Text="Second Item" />
    <ComponentArtNav:MenuItem Text="Third Item" />
    <ComponentArtNav:MenuItem Text="Fourth Item" />
    <ComponentArtNav:MenuItem Text="Fifth Item" >
	<ComponentArtNav:MenuItem Text="First Item" />
	<ComponentArtNav:MenuItem Text="Second Item" />
	<ComponentArtNav:MenuItem Text="Third Item" />
	<ComponentArtNav:MenuItem Text="Fourth Item" />
	<ComponentArtNav:MenuItem Text="Fifth Item" />
    </ComponentArtNav:MenuItem>
</ComponentArtNav:Menu>

Figure 2, the solution:

 

 

Posted to Jeremy Rodgers by

Posted on Wed Nov 25, 2009 @ 8:30 AM

Filed under: , ,

Comments

There are currently no comments for this blog post.

Anonymous comments are not allowed. Click here to log in or create an account.

Copyright © 2010 ComponentArt, Inc. All rights reserved.