Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

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.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

Using Resources

Closed Thread
 
Thread Tools Display Modes
Old 01-31-2006   #1 (permalink)
Erno
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


Old 01-31-2006   #2 (permalink)
Erno
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
>



Old 01-31-2006   #3 (permalink)
Nick Kramer [MSFT]
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
>>

>
>



Old 01-31-2006   #4 (permalink)
Erno
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
>>>

>>
>>

>
>



Closed Thread

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








Vistax64.com 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 2005-2008

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 47 48 49 50