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 - Reuse Background for multiple pages

 
 
Old 04-04-2006   #1 (permalink)
Sam Jost


 
 

Reuse Background for multiple pages

I've got an xaml browserlike app with a few pages, and I want to use
the same background in all my pages.

How can I reuse the background without having to copy it in every
page.xaml file? Can I put it in a resource and reference this, or
something?

thanks,
Sam


My System SpecsSystem Spec
Old 04-04-2006   #2 (permalink)
CosminB [BRT]


 
 

Re: Reuse Background for multiple pages

I also want to know how to do this kind of things. For example I have a
large xaml file which describes a 3D object, but if I insert it in my
main user interface file, it will be a mess. So I want to put the
object in a separate xaml file, and have it referenced in the user
interface xaml. How do we do this? I've looked over MergedDictionaries,
but I can't really figure out how to achieve the functionality I want.

For example, let's say that I have defined a label control in my
separate xaml file (Dictionary1.xaml):

----
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>

<Label x:Key="MyLabel">
Some Text
</Label>
</ResourceDictionary>
----

I know how to reference the resource in my main file, but I don't know
how to put the label inside the grid:

----
<Window x:Class="WindowsApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WindowsApplication1" Height="300" Width="300"
>

<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Dictionary1.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid>
[.......]
</Grid>
</Window>
----

What should I put in place of "[.....]" to have the label inside the
grid? Someone knows?

Cheers,
Cosmin.

My System SpecsSystem Spec
Old 04-04-2006   #3 (permalink)
viliescu


 
 

Re: Reuse Background for multiple pages

Put <StaticResource ResourceKey="MyLabel"/>
--
Valentin Iliescu [MVP C#]


"CosminB [BRT]" wrote:

> I also want to know how to do this kind of things. For example I have a
> large xaml file which describes a 3D object, but if I insert it in my
> main user interface file, it will be a mess. So I want to put the
> object in a separate xaml file, and have it referenced in the user
> interface xaml. How do we do this? I've looked over MergedDictionaries,
> but I can't really figure out how to achieve the functionality I want.
>
> For example, let's say that I have defined a label control in my
> separate xaml file (Dictionary1.xaml):
>
> ----
> <ResourceDictionary
> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
> >

> <Label x:Key="MyLabel">
> Some Text
> </Label>
> </ResourceDictionary>
> ----
>
> I know how to reference the resource in my main file, but I don't know
> how to put the label inside the grid:
>
> ----
> <Window x:Class="WindowsApplication1.Window1"
> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
> Title="WindowsApplication1" Height="300" Width="300"
> >

> <Window.Resources>
> <ResourceDictionary>
> <ResourceDictionary.MergedDictionaries>
> <ResourceDictionary Source="Dictionary1.xaml" />
> </ResourceDictionary.MergedDictionaries>
> </ResourceDictionary>
> </Window.Resources>
> <Grid>
> [.......]
> </Grid>
> </Window>
> ----
>
> What should I put in place of "[.....]" to have the label inside the
> grid? Someone knows?
>
> Cheers,
> Cosmin.
>
>

My System SpecsSystem Spec
Old 04-04-2006   #4 (permalink)
CosminB [BRT]


 
 

Re: Reuse Background for multiple pages

Thank you both for your quick replies.

Cosmin

My System SpecsSystem Spec
Old 04-04-2006   #5 (permalink)
CosminB [BRT]


 
 

Re: Reuse Background for multiple pages

I've just tested it, it works, but I get a warning when placing the
StaticResource element inside the Grid element. It says it is invalid,
as it wasn't expected there. What's the proper way to add the
StaticResource to the Grid? Is there a nicer way?

My System SpecsSystem Spec
Old 04-04-2006   #6 (permalink)
Nick Kramer [MSFT]


 
 

Re: Reuse Background for multiple pages

what is the exact error message & call stack? Thanks.

--
-Nick Kramer [MSFT]

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

"CosminB [BRT]" <cosminb@gmail.com> wrote in message
news:1144171652.265280.227260@t31g2000cwb.googlegroups.com...
> I've just tested it, it works, but I get a warning when placing the
> StaticResource element inside the Grid element. It says it is invalid,
> as it wasn't expected there. What's the proper way to add the
> StaticResource to the Grid? Is there a nicer way?
>



My System SpecsSystem Spec
Old 04-04-2006   #7 (permalink)
CosminB [BRT]


 
 

Re: Reuse Background for multiple pages

There is no error message, just a warning, when editing the xaml file.
Now it looks like this:

<Window x:Class="WindowsApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WindowsApplication1" Height="300" Width="300"
>

<Window.Resources>
<ResourceDictionary Source="Dictionary1.xaml" />
</Window.Resources>
<Grid>
<StaticResource ResourceKey="MyLabel" />
</Grid>
</Window>

It says that StaticResource isn't a valid child of Grid. And what I
want to know is: what's the proper way to do it, without getting the
warning? I suppose there is another, correct way.

My System SpecsSystem Spec
Old 04-04-2006   #8 (permalink)
Ifeanyi Echeruo [MSFT]


 
 

Re: Reuse Background for multiple pages

You can safely ignore the warning.
This is a limitation of how wpf's vs extensions currently provide
intellisense support.
We basically use an xsd in the interim but xsd is quite limited for the
purpose of validating xaml.
We are working on better intellisense support

-- Ifeanyi Echeruo [MSFT]
This posting is provided "AS IS" with no warranties, and confers no rights.

"CosminB [BRT]" <cosminb@gmail.com> wrote in message
news:1144191158.837132.227530@v46g2000cwv.googlegroups.com...
> There is no error message, just a warning, when editing the xaml file.
> Now it looks like this:
>
> <Window x:Class="WindowsApplication1.Window1"
> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
> Title="WindowsApplication1" Height="300" Width="300"
> >

> <Window.Resources>
> <ResourceDictionary Source="Dictionary1.xaml" />
> </Window.Resources>
> <Grid>
> <StaticResource ResourceKey="MyLabel" />
> </Grid>
> </Window>
>
> It says that StaticResource isn't a valid child of Grid. And what I
> want to know is: what's the proper way to do it, without getting the
> warning? I suppose there is another, correct way.
>



My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Having trouble with no background on internet pages.n .NET General
Scanning with multiple pages Vista print fax & scan
Print & Spool Multiple Pages Vista print fax & scan
Vista & HP PSC - How to scan multiple pages from flatbed? Vista print fax & scan
scanning a document. I want to be able to create multiple pages. Vista print fax & scan


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