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

How to Compose a Page From Grids Defined Outide the Page?

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 11-10-2006   #1 (permalink)
Chris Moore
Guest


 

How to Compose a Page From Grids Defined Outide the Page?

Consider the following Scenario:

I have a xaml project which contains 3 grids defined in separate XAML
files, e.g.,

Grid1.xaml
-----------------------
<Grid x:Class="Grid1">
//content
</Grid>

Grid2.xaml
-----------------------
<Grid x:Class="Grid2">
//content
</Grid>

Grid3.xaml
-----------------------
<Grid x:Class="Grid3">
//content
</Grid>

Now, How does one construct a page that displays these grids in, say, a
Stack Panel?

Thanks


My System SpecsSystem Spec
Old 11-10-2006   #2 (permalink)
Bob
Guest


 

Re: How to Compose a Page From Grids Defined Outide the Page?

In article <1163173383.530241.170150@h54g2000cwb.googlegroups.com>,
CMoore@gmail.com says...
> Consider the following Scenario:
>
> I have a xaml project which contains 3 grids defined in separate XAML
> files, e.g.,
>
> Grid1.xaml
> -----------------------
> <Grid x:Class="Grid1">
> //content
> </Grid>
>
> Grid2.xaml
> -----------------------
> <Grid x:Class="Grid2">
> //content
> </Grid>
>
> Grid3.xaml
> -----------------------
> <Grid x:Class="Grid3">
> //content
> </Grid>
>
> Now, How does one construct a page that displays these grids in, say, a
> Stack Panel?
>
> Thanks
>
>


Given 3 XAML files in the same directory as the exe..

<!-- xaml1.xaml -->
<Button
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" >
Buton1</Button>

<!-- xaml2.xaml -->
<Button
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" >
Buton1</Button>

<!-- xaml3.xaml -->
<Button
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" >
Buton1</Button>

this XAML...

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

<Grid Name="Grid1" Loaded="Grid1_Loaded">
<StackPanel Name="stackPanel1" />
</Grid>
</Window>

Married with this code behind... should do the trick

using System;
using System.Windows;
using System.Windows.Markup; //XamlReader
using System.IO;
using System.Xml;

namespace buildGUIviaXamlReader
{
public partial class Window1 : System.Windows.Window
{
public Window1()
{
InitializeComponent();
this.Grid1.Loaded += new RoutedEventHandler(Grid1
_Loaded);
}

void Grid1_Loaded(object sender, RoutedEventArgs e)
{
stackPanel1.Children.Clear();
LoadSomeXaml("xaml1.xaml");
LoadSomeXaml("xaml2.xaml");
LoadSomeXaml("xaml3.xaml");
}

protected void LoadSomeXaml(string Xaml)
{
try
{
XmlTextReader xmlreader = new XmlTextReader
(Xaml);
UIElement el = (UIElement)XamlReader.Load
(xmlreader);
this.stackPanel1.Children.Add(el);
}
catch (Exception exc)
{
MessageBox.Show(exc.Message, Title);
}
}
}
}
My System SpecsSystem Spec
Old 11-10-2006   #3 (permalink)
Bob
Guest


 

Re: How to Compose a Page From Grids Defined Outide the Page?

In article <1163173383.530241.170150@h54g2000cwb.googlegroups.com>,
CMoore@gmail.com says...
> Consider the following Scenario:
>
> I have a xaml project which contains 3 grids defined in separate XAML
> files, e.g.,
>
> Grid1.xaml
> -----------------------
> <Grid x:Class="Grid1">
> //content
> </Grid>
>
> Grid2.xaml
> -----------------------
> <Grid x:Class="Grid2">
> //content
> </Grid>
>
> Grid3.xaml
> -----------------------
> <Grid x:Class="Grid3">
> //content
> </Grid>
>
> Now, How does one construct a page that displays these grids in, say, a
> Stack Panel?
>
> Thanks
>
>


Given 3 XAML files in the same directory as the exe..

<!-- xaml1.xaml -->
<Button
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" >
Buton1</Button>

<!-- xaml2.xaml -->
<Button
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" >
Buton1</Button>

<!-- xaml3.xaml -->
<Button
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" >
Buton1</Button>

this XAML...

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

<Grid Name="Grid1" Loaded="Grid1_Loaded">
<StackPanel Name="stackPanel1" />
</Grid>
</Window>

Married with this code behind... should do the trick

using System;
using System.Windows;
using System.Windows.Markup; //XamlReader
using System.IO;
using System.Xml;

namespace buildGUIviaXamlReader
{
public partial class Window1 : System.Windows.Window
{
public Window1()
{
InitializeComponent();
this.Grid1.Loaded += new RoutedEventHandler(Grid1
_Loaded);
}

void Grid1_Loaded(object sender, RoutedEventArgs e)
{
stackPanel1.Children.Clear();
LoadSomeXaml("xaml1.xaml");
LoadSomeXaml("xaml2.xaml");
LoadSomeXaml("xaml3.xaml");
}

protected void LoadSomeXaml(string Xaml)
{
try
{
XmlTextReader xmlreader = new XmlTextReader
(Xaml);
UIElement el = (UIElement)XamlReader.Load
(xmlreader);
this.stackPanel1.Children.Add(el);
}
catch (Exception exc)
{
MessageBox.Show(exc.Message, Title);
}
}
}
}
My System SpecsSystem Spec
Old 11-10-2006   #4 (permalink)
Chris Moore
Guest


 

Re: How to Compose a Page From Grids Defined Outide the Page?

Bog,

Thanks for your response and the example.

Is there no declarative way that this can be accomplished via XAML
only? I would like to be able to build the page that is composed of the
grids entirely in XAML.


There must be a simple way to do this but after much searching I cannot
find an example.

Chris.

Bob wrote:
> In article <1163173383.530241.170150@h54g2000cwb.googlegroups.com>,
> CMoore@gmail.com says...
> > Consider the following Scenario:
> >
> > I have a xaml project which contains 3 grids defined in separate XAML
> > files, e.g.,
> >
> > Grid1.xaml
> > -----------------------
> > <Grid x:Class="Grid1">
> > //content
> > </Grid>
> >
> > Grid2.xaml
> > -----------------------
> > <Grid x:Class="Grid2">
> > //content
> > </Grid>
> >
> > Grid3.xaml
> > -----------------------
> > <Grid x:Class="Grid3">
> > //content
> > </Grid>
> >
> > Now, How does one construct a page that displays these grids in, say, a
> > Stack Panel?
> >
> > Thanks
> >
> >

>
> Given 3 XAML files in the same directory as the exe..
>
> <!-- xaml1.xaml -->
> <Button
> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" >
> Buton1</Button>
>
> <!-- xaml2.xaml -->
> <Button
> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" >
> Buton1</Button>
>
> <!-- xaml3.xaml -->
> <Button
> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" >
> Buton1</Button>
>
> this XAML...
>
> <Window x:Class="buildGUIviaXamlReader.Window1"
> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
> Title="buildGUIviaXamlReader" Height="300" Width="300"
> >

> <Grid Name="Grid1" Loaded="Grid1_Loaded">
> <StackPanel Name="stackPanel1" />
> </Grid>
> </Window>
>
> Married with this code behind... should do the trick
>
> using System;
> using System.Windows;
> using System.Windows.Markup; //XamlReader
> using System.IO;
> using System.Xml;
>
> namespace buildGUIviaXamlReader
> {
> public partial class Window1 : System.Windows.Window
> {
> public Window1()
> {
> InitializeComponent();
> this.Grid1.Loaded += new RoutedEventHandler(Grid1
> _Loaded);
> }
>
> void Grid1_Loaded(object sender, RoutedEventArgs e)
> {
> stackPanel1.Children.Clear();
> LoadSomeXaml("xaml1.xaml");
> LoadSomeXaml("xaml2.xaml");
> LoadSomeXaml("xaml3.xaml");
> }
>
> protected void LoadSomeXaml(string Xaml)
> {
> try
> {
> XmlTextReader xmlreader = new XmlTextReader
> (Xaml);
> UIElement el = (UIElement)XamlReader.Load
> (xmlreader);
> this.stackPanel1.Children.Add(el);
> }
> catch (Exception exc)
> {
> MessageBox.Show(exc.Message, Title);
> }
> }
> }
> }


My System SpecsSystem Spec
Old 11-10-2006   #5 (permalink)
Chris Moore
Guest


 

Re: How to Compose a Page From Grids Defined Outide the Page?

Bog,

Thanks for your response and the example.

Is there no declarative way that this can be accomplished via XAML
only? I would like to be able to build the page that is composed of the
grids entirely in XAML.


There must be a simple way to do this but after much searching I cannot
find an example.

Chris.

Bob wrote:
> In article <1163173383.530241.170150@h54g2000cwb.googlegroups.com>,
> CMoore@gmail.com says...
> > Consider the following Scenario:
> >
> > I have a xaml project which contains 3 grids defined in separate XAML
> > files, e.g.,
> >
> > Grid1.xaml
> > -----------------------
> > <Grid x:Class="Grid1">
> > //content
> > </Grid>
> >
> > Grid2.xaml
> > -----------------------
> > <Grid x:Class="Grid2">
> > //content
> > </Grid>
> >
> > Grid3.xaml
> > -----------------------
> > <Grid x:Class="Grid3">
> > //content
> > </Grid>
> >
> > Now, How does one construct a page that displays these grids in, say, a
> > Stack Panel?
> >
> > Thanks
> >
> >

>
> Given 3 XAML files in the same directory as the exe..
>
> <!-- xaml1.xaml -->
> <Button
> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" >
> Buton1</Button>
>
> <!-- xaml2.xaml -->
> <Button
> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" >
> Buton1</Button>
>
> <!-- xaml3.xaml -->
> <Button
> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" >
> Buton1</Button>
>
> this XAML...
>
> <Window x:Class="buildGUIviaXamlReader.Window1"
> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
> Title="buildGUIviaXamlReader" Height="300" Width="300"
> >

> <Grid Name="Grid1" Loaded="Grid1_Loaded">
> <StackPanel Name="stackPanel1" />
> </Grid>
> </Window>
>
> Married with this code behind... should do the trick
>
> using System;
> using System.Windows;
> using System.Windows.Markup; //XamlReader
> using System.IO;
> using System.Xml;
>
> namespace buildGUIviaXamlReader
> {
> public partial class Window1 : System.Windows.Window
> {
> public Window1()
> {
> InitializeComponent();
> this.Grid1.Loaded += new RoutedEventHandler(Grid1
> _Loaded);
> }
>
> void Grid1_Loaded(object sender, RoutedEventArgs e)
> {
> stackPanel1.Children.Clear();
> LoadSomeXaml("xaml1.xaml");
> LoadSomeXaml("xaml2.xaml");
> LoadSomeXaml("xaml3.xaml");
> }
>
> protected void LoadSomeXaml(string Xaml)
> {
> try
> {
> XmlTextReader xmlreader = new XmlTextReader
> (Xaml);
> UIElement el = (UIElement)XamlReader.Load
> (xmlreader);
> this.stackPanel1.Children.Add(el);
> }
> catch (Exception exc)
> {
> MessageBox.Show(exc.Message, Title);
> }
> }
> }
> }


My System SpecsSystem Spec
Old 11-11-2006   #6 (permalink)
Pon
Guest


 

Re: How to Compose a Page From Grids Defined Outide the Page?

Do I understand well what u want ? Because I don't really see where the
trouble is. Why don't u make these grids application scope resources ?

"Chris Moore" <CMoore@gmail.com> a écrit dans le message de news:
1163173383.530241.170150@h54g2000cwb.googlegroups.com...
> Consider the following Scenario:
>
> I have a xaml project which contains 3 grids defined in separate XAML
> files, e.g.,
>
> Grid1.xaml
> -----------------------
> <Grid x:Class="Grid1">
> //content
> </Grid>
>
> Grid2.xaml
> -----------------------
> <Grid x:Class="Grid2">
> //content
> </Grid>
>
> Grid3.xaml
> -----------------------
> <Grid x:Class="Grid3">
> //content
> </Grid>
>
> Now, How does one construct a page that displays these grids in, say, a
> Stack Panel?
>
> Thanks
>



My System SpecsSystem Spec
Old 11-11-2006   #7 (permalink)
Pon
Guest


 

Re: How to Compose a Page From Grids Defined Outide the Page?

Do I understand well what u want ? Because I don't really see where the
trouble is. Why don't u make these grids application scope resources ?

"Chris Moore" <CMoore@gmail.com> a écrit dans le message de news:
1163173383.530241.170150@h54g2000cwb.googlegroups.com...
> Consider the following Scenario:
>
> I have a xaml project which contains 3 grids defined in separate XAML
> files, e.g.,
>
> Grid1.xaml
> -----------------------
> <Grid x:Class="Grid1">
> //content
> </Grid>
>
> Grid2.xaml
> -----------------------
> <Grid x:Class="Grid2">
> //content
> </Grid>
>
> Grid3.xaml
> -----------------------
> <Grid x:Class="Grid3">
> //content
> </Grid>
>
> Now, How does one construct a page that displays these grids in, say, a
> Stack Panel?
>
> Thanks
>



My System SpecsSystem Spec
Old 11-11-2006   #8 (permalink)
Douglas Stockwell
Guest


 

Re: How to Compose a Page From Grids Defined Outide the Page?

Read up on namespace declarations. You should be able to do the following:

<Window xmlns:local="clr-namespace:YourNamespace">
<StackPanel>
<local:Grid1 />
<local:Grid2 />
<local:Grid3 />
</StackPanel>
</Window>

- Doug

"Chris Moore" <CMoore@gmail.com> wrote in message
news:1163223265.763237.287150@m7g2000cwm.googlegroups.com...
> Bog,
>
> Thanks for your response and the example.
>
> Is there no declarative way that this can be accomplished via XAML
> only? I would like to be able to build the page that is composed of the
> grids entirely in XAML.
>
>
> There must be a simple way to do this but after much searching I cannot
> find an example.
>
> Chris.
>
> Bob wrote:
>> In article <1163173383.530241.170150@h54g2000cwb.googlegroups.com>,
>> CMoore@gmail.com says...
>> > Consider the following Scenario:
>> >
>> > I have a xaml project which contains 3 grids defined in separate XAML
>> > files, e.g.,
>> >
>> > Grid1.xaml
>> > -----------------------
>> > <Grid x:Class="Grid1">
>> > //content
>> > </Grid>
>> >
>> > Grid2.xaml
>> > -----------------------
>> > <Grid x:Class="Grid2">
>> > //content
>> > </Grid>
>> >
>> > Grid3.xaml
>> > -----------------------
>> > <Grid x:Class="Grid3">
>> > //content
>> > </Grid>
>> >
>> > Now, How does one construct a page that displays these grids in, say, a
>> > Stack Panel?
>> >
>> > Thanks
>> >
>> >

>>
>> Given 3 XAML files in the same directory as the exe..
>>
>> <!-- xaml1.xaml -->
>> <Button
>> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" >
>> Buton1</Button>
>>
>> <!-- xaml2.xaml -->
>> <Button
>> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" >
>> Buton1</Button>
>>
>> <!-- xaml3.xaml -->
>> <Button
>> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" >
>> Buton1</Button>
>>
>> this XAML...
>>
>> <Window x:Class="buildGUIviaXamlReader.Window1"
>> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
>> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>> Title="buildGUIviaXamlReader" Height="300" Width="300"
>> >

>> <Grid Name="Grid1" Loaded="Grid1_Loaded">
>> <StackPanel Name="stackPanel1" />
>> </Grid>
>> </Window>
>>
>> Married with this code behind... should do the trick
>>
>> using System;
>> using System.Windows;
>> using System.Windows.Markup; //XamlReader
>> using System.IO;
>> using System.Xml;
>>
>> namespace buildGUIviaXamlReader
>> {
>> public partial class Window1 : System.Windows.Window
>> {
>> public Window1()
>> {
>> InitializeComponent();
>> this.Grid1.Loaded += new RoutedEventHandler(Grid1
>> _Loaded);
>> }
>>
>> void Grid1_Loaded(object sender, RoutedEventArgs e)
>> {
>> stackPanel1.Children.Clear();
>> LoadSomeXaml("xaml1.xaml");
>> LoadSomeXaml("xaml2.xaml");
>> LoadSomeXaml("xaml3.xaml");
>> }
>>
>> protected void LoadSomeXaml(string Xaml)
>> {
>> try
>> {
>> XmlTextReader xmlreader = new XmlTextReader
>> (Xaml);
>> UIElement el = (UIElement)XamlReader.Load
>> (xmlreader);
>> this.stackPanel1.Children.Add(el);
>> }
>> catch (Exception exc)
>> {
>> MessageBox.Show(exc.Message, Title);
>> }
>> }
>> }
>> }

>


My System SpecsSystem Spec
Old 11-11-2006   #9 (permalink)
Douglas Stockwell
Guest


 

Re: How to Compose a Page From Grids Defined Outide the Page?

Read up on namespace declarations. You should be able to do the following:

<Window xmlns:local="clr-namespace:YourNamespace">
<StackPanel>
<local:Grid1 />
<local:Grid2 />
<local:Grid3 />
</StackPanel>
</Window>

- Doug

"Chris Moore" <CMoore@gmail.com> wrote in message
news:1163223265.763237.287150@m7g2000cwm.googlegroups.com...
> Bog,
>
> Thanks for your response and the example.
>
> Is there no declarative way that this can be accomplished via XAML
> only? I would like to be able to build the page that is composed of the
> grids entirely in XAML.
>
>
> There must be a simple way to do this but after much searching I cannot
> find an example.
>
> Chris.
>
> Bob wrote:
>> In article <1163173383.530241.170150@h54g2000cwb.googlegroups.com>,
>> CMoore@gmail.com says...
>> > Consider the following Scenario:
>> >
>> > I have a xaml project which contains 3 grids defined in separate XAML
>> > files, e.g.,
>> >
>> > Grid1.xaml
>> > -----------------------
>> > <Grid x:Class="Grid1">
>> > //content
>> > </Grid>
>> >
>> > Grid2.xaml
>> > -----------------------
>> > <Grid x:Class="Grid2">
>> > //content
>> > </Grid>
>> >
>> > Grid3.xaml
>> > -----------------------
>> > <Grid x:Class="Grid3">
>> > //content
>> > </Grid>
>> >
>> > Now, How does one construct a page that displays these grids in, say, a
>> > Stack Panel?
>> >
>> > Thanks
>> >
>> >

>>
>> Given 3 XAML files in the same directory as the exe..
>>
>> <!-- xaml1.xaml -->
>> <Button
>> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" >
>> Buton1</Button>
>>
>> <!-- xaml2.xaml -->
>> <Button
>> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" >
>> Buton1</Button>
>>
>> <!-- xaml3.xaml -->
>> <Button
>> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" >
>> Buton1</Button>
>>
>> this XAML...
>>
>> <Window x:Class="buildGUIviaXamlReader.Window1"
>> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
>> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>> Title="buildGUIviaXamlReader" Height="300" Width="300"
>> >

>> <Grid Name="Grid1" Loaded="Grid1_Loaded">
>> <StackPanel Name="stackPanel1" />
>> </Grid>
>> </Window>
>>
>> Married with this code behind... should do the trick
>>
>> using System;
>> using System.Windows;
>> using System.Windows.Markup; //XamlReader
>> using System.IO;
>> using System.Xml;
>>
>> namespace buildGUIviaXamlReader
>> {
>> public partial class Window1 : System.Windows.Window
>> {
>> public Window1()
>> {
>> InitializeComponent();
>> this.Grid1.Loaded += new RoutedEventHandler(Grid1
>> _Loaded);
>> }
>>
>> void Grid1_Loaded(object sender, RoutedEventArgs e)
>> {
>> stackPanel1.Children.Clear();
>> LoadSomeXaml("xaml1.xaml");
>> LoadSomeXaml("xaml2.xaml");
>> LoadSomeXaml("xaml3.xaml");
>> }
>>
>> protected void LoadSomeXaml(string Xaml)
>> {
>> try
>> {
>> XmlTextReader xmlreader = new XmlTextReader
>> (Xaml);
>> UIElement el = (UIElement)XamlReader.Load
>> (xmlreader);
>> this.stackPanel1.Children.Add(el);
>> }
>> catch (Exception exc)
>> {
>> MessageBox.Show(exc.Message, Title);
>> }
>> }
>> }
>> }

>


My System SpecsSystem Spec
Old 11-11-2006   #10 (permalink)
Chris Moore
Guest


 

Re: How to Compose a Page From Grids Defined Outide the Page?

Thanks; that worked like a charm and was exactly what I was looking
for. I knew there must be a simple way to do it.....



Douglas Stockwell wrote:
> Read up on namespace declarations. You should be able to do the following:
>
> <Window xmlns:local="clr-namespace:YourNamespace">
> <StackPanel>
> <local:Grid1 />
> <local:Grid2 />
> <local:Grid3 />
> </StackPanel>
> </Window>
>
> - Doug
>
> "Chris Moore" <CMoore@gmail.com> wrote in message
> news:1163223265.763237.287150@m7g2000cwm.googlegroups.com...
> > Bog,
> >
> > Thanks for your response and the example.
> >
> > Is there no declarative way that this can be accomplished via XAML
> > only? I would like to be able to build the page that is composed of the
> > grids entirely in XAML.
> >
> >
> > There must be a simple way to do this but after much searching I cannot
> > find an example.
> >
> > Chris.
> >
> > Bob wrote:
> >> In article <1163173383.530241.170150@h54g2000cwb.googlegroups.com>,
> >> CMoore@gmail.com says...
> >> > Consider the following Scenario:
> >> >
> >> > I have a xaml project which contains 3 grids defined in separate XAML
> >> > files, e.g.,
> >> >
> >> > Grid1.xaml
> >> > -----------------------
> >> > <Grid x:Class="Grid1">
> >> > //content
> >> > </Grid>
> >> >
> >> > Grid2.xaml
> >> > -----------------------
> >> > <Grid x:Class="Grid2">
> >> > //content
> >> > </Grid>
> >> >
> >> > Grid3.xaml
> >> > -----------------------
> >> > <Grid x:Class="Grid3">
> >> > //content
> >> > </Grid>
> >> >
> >> > Now, How does one construct a page that displays these grids in, say, a
> >> > Stack Panel?
> >> >
> >> > Thanks
> >> >
> >> >
> >>
> >> Given 3 XAML files in the same directory as the exe..
> >>
> >> <!-- xaml1.xaml -->
> >> <Button
> >> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" >
> >> Buton1</Button>
> >>
> >> <!-- xaml2.xaml -->
> >> <Button
> >> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" >
> >> Buton1</Button>
> >>
> >> <!-- xaml3.xaml -->
> >> <Button
> >> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" >
> >> Buton1</Button>
> >>
> >> this XAML...
> >>
> >> <Window x:Class="buildGUIviaXamlReader.Window1"
> >> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
> >> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
> >> Title="buildGUIviaXamlReader" Height="300" Width="300"
> >> >
> >> <Grid Name="Grid1" Loaded="Grid1_Loaded">
> >> <StackPanel Name="stackPanel1" />
> >> </Grid>
> >> </Window>
> >>
> >> Married with this code behind... should do the trick
> >>
> >> using System;
> >> using System.Windows;
> >> using System.Windows.Markup; //XamlReader
> >> using System.IO;
> >> using System.Xml;
> >>
> >> namespace buildGUIviaXamlReader
> >> {
> >> public partial class Window1 : System.Windows.Window
> >> {
> >> public Window1()
> >> {
> >> InitializeComponent();
> >> this.Grid1.Loaded += new RoutedEventHandler(Grid1
> >> _Loaded);
> >> }
> >>
> >> void Grid1_Loaded(object sender, RoutedEventArgs e)
> >> {
> >> stackPanel1.Children.Clear();
> >> LoadSomeXaml("xaml1.xaml");
> >> LoadSomeXaml("xaml2.xaml");
> >> LoadSomeXaml("xaml3.xaml");
> >> }
> >>
> >> protected void LoadSomeXaml(string Xaml)
> >> {
> >> try
> >> {
> >> XmlTextReader xmlreader = new XmlTextReader
> >> (Xaml);
> >> UIElement el = (UIElement)XamlReader.Load
> >> (xmlreader);
> >> this.stackPanel1.Children.Add(el);
> >> }
> >> catch (Exception exc)
> >> {
> >> MessageBox.Show(exc.Message, Title);
> >> }
> >> }
> >> }
> >> }

> >


My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
page disappears when Mouse moved off page CDNHart General Discussion 10 07-31-2008 05:02 PM
Blue Screen - Page fault in non page area Gregstagg985 Vista performance & maintenance 0 07-22-2008 04:31 PM
web page big rick Vista General 6 03-20-2008 07:52 AM
Error Message - Page error in non page area Don Vista hardware & devices 1 08-18-2007 11:46 AM
IE7 Crashes when loading home page-any home page Jim Marcum Vista General 5 04-14-2007 02:29 PM


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 51