Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - "nested" XAML ?

 
 
Old 01-31-2006   #1 (permalink)
Griff


 
 

"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#)

My System SpecsSystem Spec
Old 01-31-2006   #2 (permalink)
Drew Marsh


 
 

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


My System SpecsSystem Spec
Old 01-31-2006   #3 (permalink)
Griff


 
 

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

My System SpecsSystem Spec
Old 01-31-2006   #4 (permalink)
Nick Kramer [MSFT]


 
 

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



My System SpecsSystem Spec
Old 01-31-2006   #5 (permalink)
Griff


 
 

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

>
>
>

My System SpecsSystem Spec
 

Thread Tools



Vista Forums 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 Ltd

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