![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| | #3 (permalink) |
| | 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 Specs![]() |
| | #4 (permalink) |
| | Re: Reuse Background for multiple pages Thank you both for your quick replies. Cosmin |
My System Specs![]() |
| | #5 (permalink) |
| | 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 Specs![]() |
| | #6 (permalink) |
| | 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 Specs![]() |
| | #7 (permalink) |
| | 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 Specs![]() |
| | #8 (permalink) |
| | 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 Specs![]() |
| 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 | |||