![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | 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 |
| | #2 (permalink) |
| Guest | Re: Using Resources 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 > |
| | #3 (permalink) |
| Guest | Re: Using Resources <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 >> > > |
| | #4 (permalink) |
| Guest | 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 >>> >> >> > > |
| |
| |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Not enough resources | Eric the Grey | Vista hardware & devices | 4 | 03-13-2007 10:13 PM |
| resources | Banjaxster | Vista hardware & devices | 10 | 11-13-2006 09:35 PM |
| Best resources for Development? | Dan | PowerShell | 1 | 08-24-2006 11:44 AM |
| SearchIndexer.exe Resources | =?Utf-8?B?V2FycmVu?= | Vista General | 0 | 08-06-2006 10:58 PM |
| Vista using 100% resources | Exiddor | Vista General | 0 | 06-16-2006 01:02 AM |