![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| | #3 (permalink) |
| | 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 Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Send To Context Menu - Restore Default Menu Items | Tutorials | |||
| Missing Start Menu/Toolbar and desktop items! | Vista General | |||