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

"nested" XAML ?

Closed Thread
 
Thread Tools Display Modes
Old 01-31-2006   #1 (permalink)
Griff
Guest


 

"nested" XAML ?

I would ideally like to do the equivalent of #include in a markup file, to
shop my applications resources becoming unwieldy. Is there a way to do it ?

For example

----MyApp.xaml--------
....
<somehow include "MyStyles.xaml">
<Somehow include "MyControlTemplates.xaml">
....


--
Griff
(trying to make an industrial UI with XAML/WPF/c#)
Old 01-31-2006   #2 (permalink)
Drew Marsh
Guest


 

Re: "nested" XAML ?

Griff wrote:

> I would ideally like to do the equivalent of #include in a markup
> file, to shop my applications resources becoming unwieldy. Is there a
> way to do it ?


You can include external ResourceDictionary like so:

<ResourceDictionary Source="MyResources.xaml"/>

Where the file MyResources.xaml is part of your build and is marked as type
"Content" so it is built into the assembly correctly.

HTH,
Drew


Old 01-31-2006   #3 (permalink)
Griff
Guest


 

Re: "nested" XAML ?

I'm still not sure I understand.

are you saying that
- in MyApp.xaml I would put

<ResourceDictionary Source="myStyles.xaml">

- and Styles.xaml would look like
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/avalon/2005"
xmlns:x="http://schemas.microsoft.com/winfx/xaml/2005">
....
<Style ...../>
...
</ResourceDictionary>


So far I have not managed to get any sort of permutation working.

I get clean compile then runtime error such as
"Cannot assign value 'Styles.xaml' to property
'System.Windows.ResourceDictionary.Source'



--
Griff
(trying to make an industrial UI with XAML/WPF/c#)


"Drew Marsh" wrote:

> Griff wrote:
>
> > I would ideally like to do the equivalent of #include in a markup
> > file, to shop my applications resources becoming unwieldy. Is there a
> > way to do it ?

>
> You can include external ResourceDictionary like so:
>
> <ResourceDictionary Source="MyResources.xaml"/>
>
> Where the file MyResources.xaml is part of your build and is marked as type
> "Content" so it is built into the assembly correctly.
>
> HTH,
> Drew
>
>
>

Old 01-31-2006   #4 (permalink)
Drew Marsh
Guest


 

Re: "nested" XAML ?

Griff wrote:

> I'm still not sure I understand.
>
> are you saying that - in MyApp.xaml I would put


Yes, you can put it in MyApp.xaml or any other place that takes a ResourceDictionary
instance...

> <ResourceDictionary Source="myStyles.xaml">
>
> - and Styles.xaml would look like
> <ResourceDictionary
> xmlns="http://schemas.microsoft.com/winfx/avalon/2005"
> xmlns:x="http://schemas.microsoft.com/winfx/xaml/2005">
> ...
> <Style ...../>
> ..
> </ResourceDictionary>


That is also correct, sorry I left that part out.

> So far I have not managed to get any sort of permutation working.
>
> I get clean compile then runtime error such as
> "Cannot assign value 'Styles.xaml' to property
> 'System.Windows.ResourceDictionary.Source'


Hmm... yeah this is starting to ring a bell now, maybe I'm forgetting something.
Did you also select to copy the Styles.xaml to the build directory? I think
that might be the part I was missing.

HTH,
Drew


Old 01-31-2006   #5 (permalink)
Nick Kramer [MSFT]
Guest


 

Re: "nested" XAML ?

See http://www.designerslove.net/2005/09...es-use-em.html
for an example.

--
-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


"Drew Marsh" <drub0y@hotmail.no.spamming.com> wrote in message
news:f01844f1e7c5c8c7e669faec2982@msnews.microsoft.com...
> Griff wrote:
>
>> I'm still not sure I understand.
>>
>> are you saying that - in MyApp.xaml I would put

>
> Yes, you can put it in MyApp.xaml or any other place that takes a
> ResourceDictionary instance...
>
>> <ResourceDictionary Source="myStyles.xaml">
>>
>> - and Styles.xaml would look like
>> <ResourceDictionary
>> xmlns="http://schemas.microsoft.com/winfx/avalon/2005"
>> xmlns:x="http://schemas.microsoft.com/winfx/xaml/2005">
>> ...
>> <Style ...../>
>> ..
>> </ResourceDictionary>

>
> That is also correct, sorry I left that part out.
>
>> So far I have not managed to get any sort of permutation working.
>>
>> I get clean compile then runtime error such as
>> "Cannot assign value 'Styles.xaml' to property
>> 'System.Windows.ResourceDictionary.Source'

>
> Hmm... yeah this is starting to ring a bell now, maybe I'm forgetting
> something. Did you also select to copy the Styles.xaml to the build
> directory? I think that might be the part I was missing.
>
> HTH,
> Drew
>
>



Old 01-31-2006   #6 (permalink)
Griff
Guest


 

Re: "nested" XAML ?

I started originally with the example from

http://www.designerslove.net/2005/09...es-use-em.html

But I find that when I do exactly that

either
- I designate the separate file as "content" (and copy to output dir) and
get the runtime error

Error at element 'ResourceDictionary' in markup file 'myapp.xaml' : Cannot
assign value 'Colours1.xaml' to property
'System.Windows.ResourceDictionary.Source'..

or
- I designate the separate file as "compile" and get the following compile
error for my separate resource dictionary file:

A namespace does not directly contain members such as fields or methods

or
- I designate the separate file as "page" and then start getting different
runtime errors concerning bits of my myapp.xaml that previously worked.
(For example, not being allowed <RowDefinition /> inside a grid inside a
control template, though previously this was accepted).


I note that the "Designers Love .NET" example claimed to be compatible with
Sept CTP. Maybe this all got broken in Nov ?





--
Griff
(trying to make an industrial UI with XAML/WPF/c#)


"Nick Kramer [MSFT]" wrote:

> See http://www.designerslove.net/2005/09...es-use-em.html
> for an example.
>
> --
> -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
>
>
> "Drew Marsh" <drub0y@hotmail.no.spamming.com> wrote in message
> news:f01844f1e7c5c8c7e669faec2982@msnews.microsoft.com...
> > Griff wrote:
> >
> >> I'm still not sure I understand.
> >>
> >> are you saying that - in MyApp.xaml I would put

> >
> > Yes, you can put it in MyApp.xaml or any other place that takes a
> > ResourceDictionary instance...
> >
> >> <ResourceDictionary Source="myStyles.xaml">
> >>
> >> - and Styles.xaml would look like
> >> <ResourceDictionary
> >> xmlns="http://schemas.microsoft.com/winfx/avalon/2005"
> >> xmlns:x="http://schemas.microsoft.com/winfx/xaml/2005">
> >> ...
> >> <Style ...../>
> >> ..
> >> </ResourceDictionary>

> >
> > That is also correct, sorry I left that part out.
> >
> >> So far I have not managed to get any sort of permutation working.
> >>
> >> I get clean compile then runtime error such as
> >> "Cannot assign value 'Styles.xaml' to property
> >> 'System.Windows.ResourceDictionary.Source'

> >
> > Hmm... yeah this is starting to ring a bell now, maybe I'm forgetting
> > something. Did you also select to copy the Styles.xaml to the build
> > directory? I think that might be the part I was missing.
> >
> > HTH,
> > Drew
> >
> >

>
>
>

Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Internet explorer "stuck" trying to display any XAML file Sergey Aldoukhov Avalon 0 01-24-2007 07:17 PM
Interpreter demo loading "loose Xaml" interface pfisk Avalon 0 05-06-2006 03:28 PM
Interpreter demo loading "loose Xaml" interface pfisk Avalon 0 05-06-2006 03:24 PM
Interpreter demo loading "loose Xaml" interface. pfisk Avalon 0 05-06-2006 03:21 PM
Can't view xaml files in IE, XamlViewer.xbap is "not trusted" news.microsoft.com Avalon 2 04-26-2006 10:00 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