![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | Using Resources Hi! From within code I can use FindResource() to find a resource identified by a key. This way I attach the same ContextMenu to multiple, runtime generated Visuals. I really like the fact that the context menu is in its own Xaml file now, so I figured it would be nice to have my main menu to reside in its own Xaml file as well... Suppose I used to have a DockPanel in my Window like this: <DockPanel LastChildFill="True" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Name="dockPanel1"> <Menu DockPanel.Dock="Top"> ... </Menu> </DockPanel> Now let's move the Menu to its own Xaml like this <Menu x:Key="MainMenu" DockPanel.Dock="Top"> ... </Menu> Now the following questions arises: How do I refer to and insert from within the DockPanel the menu? I consider DockPanel.Dock="Top" in my resourcedictionary menu very ugly (to say the least). So I'd expect a contruction like this: <DockPanel LastChildFill="True" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Name="dockPanel1"> <Menu DockPanel.Dock="Top" resourcekey="MainMenu"/> </DockPanel> Anybody any idea? Thanks! Erno |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Using Resources Nick, I tried this: <DockPanel Name="dockPanel1"> <Menu DockPanel.Dock="Top"> <StaticResource ResourceKey="MainMenu"/> </Menu> </DockPanel> (<StaticResourceExtention> couldn't be nested in the DockPanel.) But I still get the "Invalid value 'System.Windows.Controls.AccessText' for property 'Header'. Values derived from Visual or ContentElement cannot be set in a 'Template'." message... Thanks, Erno "Nick Kramer [MSFT]" <nkramer@ms.spam> wrote in message news:u1hYmgiHGHA.3144@TK2MSFTNGP11.phx.gbl... > <DockPanel> > <StaticResourceExtension ResourceKey="foo"/> > > > Where that second line is really just another syntax for {StaticResource > foo} > > -- > -Nick Kramer [MSFT] > http://blogs.msdn.com/nickkramer > > --- > This posting is provided "AS IS" with no warranties, and confers no > rights. Use of included script samples are subject to the terms specified > at http://www.microsoft.com/info/cpyright.htm > > > "Erno" <nospam> wrote in message > news:OrV9T8gHGHA.3916@TK2MSFTNGP10.phx.gbl... >> BTW: I tried Templated Controls and ran into the errormessage: >> >> Invalid value 'System.Windows.Controls.AccessText' for property 'Header'. >> Values derived from Visual or ContentElement cannot be set in a >> 'Template'. >> >> Erno >> >> "Erno" <nospam> wrote in message >> news:uwJ7LsgHGHA.916@TK2MSFTNGP10.phx.gbl... >>> Hi! >>> >>> From within code I can use FindResource() to find a resource identified >>> by a key. This way I attach the same ContextMenu to multiple, runtime >>> generated Visuals. >>> >>> I really like the fact that the context menu is in its own Xaml file >>> now, so I figured it would be nice to have my main menu to reside in its >>> own Xaml file as well... >>> >>> Suppose I used to have a DockPanel in my Window like this: >>> >>> <DockPanel LastChildFill="True" VerticalAlignment="Stretch" >>> HorizontalAlignment="Stretch" Name="dockPanel1"> >>> >>> <Menu DockPanel.Dock="Top"> >>> ... >>> </Menu> >>> >>> </DockPanel> >>> >>> Now let's move the Menu to its own Xaml like this >>> >>> <Menu x:Key="MainMenu" DockPanel.Dock="Top"> >>> ... >>> </Menu> >>> >>> Now the following questions arises: >>> >>> How do I refer to and insert from within the DockPanel the menu? >>> >>> I consider DockPanel.Dock="Top" in my resourcedictionary menu very ugly >>> (to say the least). So I'd expect a contruction like this: >>> >>> <DockPanel LastChildFill="True" VerticalAlignment="Stretch" >>> HorizontalAlignment="Stretch" Name="dockPanel1"> >>> >>> <Menu DockPanel.Dock="Top" resourcekey="MainMenu"/> >>> </DockPanel> >>> >>> Anybody any idea? >>> >>> Thanks! >>> >>> Erno >>> >> >> > > |
My System Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| VPN / Local resources | Vista networking & sharing | |||
| Not enough resources | Vista hardware & devices | |||
| resources | Vista hardware & devices | |||
| PCI to PCI Bridge not enough resources | Vista hardware & devices | |||
| Best resources for Development? | PowerShell | |||