Use two menus in a SL app

Nov 16, 2010 at 1:37 AM

Very helpful menu!

I am new to SL - is it possible to have two SL4popupmenus in one SL app, say a top menu and a pinned menu on the right of the app? How would you do this?

Thanx

Nov 17, 2010 at 1:15 PM
Hi Simone,
Sure you can. Have you tried tried to run the demo application? It
covers many scenarios, including the use of multiple menus, to get you
started and hopefully answer your question. Else just let me know and
I'll do my best to help you.

Regards

Ziad
>
Nov 17, 2010 at 1:52 PM

Hi Ziad

Thanks for the reply!

For some reason I didn't even think of the demo having multiple menus to help me with what I am trying to do :)

What I thought of is having a xaml for each menu that I want in my application. But the one just overwrites the other one then and you have two of the same menu in your app.

Should I just create the two menus in the one xaml file and position them where I want them to show in the app and use only one reference in the MainPage.xaml?

Thanks!

Nov 17, 2010 at 4:01 PM

Is it possible for you to send me a sample code where one menu 'overwrites the other' Simone?

That will help me a lot!

Nov 17, 2010 at 5:38 PM

Hi Ziad

Will post some code. If I want a main menu (e.g. file, edit, view etc.) at the top of the screen and a menu on the right in the middle which represents a "toolbar" menu, what would be the best way of implementing these menus in one application?

Thanks.

Nov 17, 2010 at 8:44 PM
Edited Nov 17, 2010 at 8:48 PM

Hi Simone,

Basically you start by adding a ListBox containing ListBoxItems as your topmost menu(the file, edit, view etc. menus in your case) to your XAML.

Suppose you've added a ListBoxItem named 'lbiFile' in XAML and you want to left click on it to get a menu. For this just add a PopupMenu control to your XAML(anywhere will do), set its LeftClickElements property as 'lbiFile' and make sure it contains some content. Now run the code, click on the item and the PopupMenu content should pop up right under it.

There is no limit to the number of menus you can add this way. There are a few related examples in the demo source so please take a look at it and let me know from there if you're still unsure about how to proceed.

Hope this has been of any help to you.

Regards

Ziad

Nov 18, 2010 at 6:31 AM

Hi Ziad

I've got it working perfectly! Thanks for the help.

I would like the second menu to have the listbox transformed so that the listbox displays vertically, is there a way to align the menu so that when the label is selected the menu aligns with the top of the listbox and not the bottom - at the moment it aligns with the bottom corner?

Thanks!!!!

Nov 18, 2010 at 10:11 AM

To rotate the ListBox you must add the following XAML code to it:

<ListBox.RenderTransform>
<CompositeTransform Rotation="90"/>
</ListBox.RenderTransform>

And for the menu orientation use the Orientation property.

Nov 18, 2010 at 4:22 PM

Thanks, I tried the code that you gave but the menu now displays over the listbox - looks like its aligning with the top right corner now (menu orientation is left).

Nov 25, 2010 at 1:37 PM

Hi Ziad. Any help with this problem??

Thanks!

Nov 26, 2010 at 2:11 PM

I suggest you add the transform code to all ListBoxes involved with the menu but if you want a more specific reply I have to ask you again for a sample code to illustrate your issue.