Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - Loading Menu and Toolbar Items From a Resource File (Page?) in WPF

 
 
Old 11-13-2006   #1 (permalink)
Bree


 
 

Loading Menu and Toolbar Items From a Resource File (Page?) in WPF

Hi,

I am VERY new to WPF and am looking for a couple of simple examples
(snippets are greatly appreciated!).

I need to load some standard menu items (File, Edit, Help etc) from a
resource file (or is it a page?). These menu items have a few child
items.

I also need to load a number of icons onto a toolbar, using a similar
technique.

I can't find any examples of what I want to do. Any help woul be very
much appreciated!


My System SpecsSystem Spec
Old 11-21-2006   #2 (permalink)
John Vanderburg


 
 

RE: Loading Menu and Toolbar Items From a Resource File(Page?) in WPF

I had trouble with this as well, but finally figured it out. Here's what I did.

1. Menu defined in resource file
<Application.Resources>
<!-- Menu and Context menu resources -->
<Menu x:Key="Menu.File">
<MenuItem Header="_File" >
<MenuItem Header="E_xit" Command="{x:Static pw:ApplicationCommands.Exit}" />
</MenuItem>
</Menu>
</Application.Resources>

2.Reference the menu resource in a Window
<DockPanel x:Name="DockPanel" LastChildFill="False">
<ToolBarTray DockPanel.Dock="Top" MinHeight="24" x:Name="ToolBarTray">
<ToolBar x:Name="Standard">
<StaticResource ResourceKey="Menu.File" />
</ToolBar>
</ToolBarTray>
</DockPanel>

You should be able to reference icons/images, etc in a similar manner.

Hope this helps

EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com
My System SpecsSystem Spec
Old 11-28-2006   #3 (permalink)
Bree


 
 

Re: Loading Menu and Toolbar Items From a Resource File (Page?) in WPF

Thank you John. I appreciate the help.

~ Bree

John wrote:
> I had trouble with this as well, but finally figured it out. Here's what I did.
>
> 1. Menu defined in resource file
> <Application.Resources>
> <!-- Menu and Context menu resources -->
> <Menu x:Key="Menu.File">
> <MenuItem Header="_File" >
> <MenuItem Header="E_xit" Command="{x:Static pw:ApplicationCommands.Exit}" />
> </MenuItem>
> </Menu>
> </Application.Resources>
>
> 2.Reference the menu resource in a Window
> <DockPanel x:Name="DockPanel" LastChildFill="False">
> <ToolBarTray DockPanel.Dock="Top" MinHeight="24" x:Name="ToolBarTray">
> <ToolBar x:Name="Standard">
> <StaticResource ResourceKey="Menu.File" />
> </ToolBar>
> </ToolBarTray>
> </DockPanel>
>
> You should be able to reference icons/images, etc in a similar manner.
>
> Hope this helps
>
> EggHeadCafe.com - .NET Developer Portal of Choice
> http://www.eggheadcafe.com


My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Send To Context Menu - Restore Default Menu Items Tutorials
Missing Start Menu/Toolbar and desktop items! Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46