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

Multiple layers or visual layout?

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 01-31-2006   #1 (permalink)
Jason Dolinger
Guest


 

Multiple layers or visual layout?

Hi all,

Starting to get into even messier questions now... Is it possible to
have multiple layers of layout going on in the application? Let's say
that I'm using a grid layout to neatly and symmetrically define a number
of controls and elements. On top of that, I wish to randomly scattered
some other overlayed things on top. That second layer really doesn't
fit into the idea of a grid layout as it is somewhat irregular, what I
really need is to manage the arrangement of those myself, which would
lend itself to an canvas.

So given that scenario, can you give a window both a grid layout and a
canvas layout, and put different controls/visuals into the different
layers? Or perhaps the answer is using the canvas for the base layout,
and then nesting a full window sized grid within that canvas. Any thoughts?

Thanks!
Jason

My System SpecsSystem Spec
Old 01-31-2006   #2 (permalink)
JosephCooney
Guest


 

RE: Multiple layers or visual layout?

Hi Jason

It is possible to use the canvas to absolutely position items within it.
Also child controls are rendered in the order that they appear in the markup
(earlier controls are rendered behind ones that appear later). If your grid
layout appears as the first child control of a top-level canvas element then
items that come after the grid can be absolutely positioned over the top of
the grid. Here is an example:

<Window x:Class="DrawingOverGridContents.Window1"
xmlns="http://schemas.microsoft.com/winfx/avalon/2005"
xmlns:x="http://schemas.microsoft.com/winfx/xaml/2005"
Title="DrawingOverGridContents"
>

<Canvas>
<Grid ShowGridLines="True" Width="200" Height="200">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Background="Orange" Grid.Column="0" Grid.Row="0">Row0,
Col0</TextBlock>
<TextBlock Background="CornflowerBlue" Grid.Column="0"
Grid.Row="1">Row1, Col0</TextBlock>
<TextBlock Background="BlanchedAlmond" Grid.Column="0"
Grid.Row="2">Row2, Col0</TextBlock>
<TextBlock Background="Red" Grid.Column="1" Grid.Row="0">Row0,
Col1</TextBlock>
<TextBlock Background="Navy" Grid.Column="1" Grid.Row="1">Row1,
Col1</TextBlock>
<TextBlock Background="FireBrick" Grid.Column="1" Grid.Row="2">Row2,
Col1</TextBlock>
</Grid>
<Border Canvas.Top="30" Canvas.Left="60" CornerRadius="5"
BorderBrush="DarkGreen" BorderThickness="2">
<TextBlock Background="Green" FontSize="32">Special!</TextBlock>
</Border>
</Canvas>
</Window>

I'd be a little worried about all the absolute positioning that this would
require however, and would try and avoid it if possible. There might also be
a way to do this all with just a grid too. I seem to remember seeing
something in John Gossman's PDC05 talk towards the end which covered
something like this, but I'm not 100% sure. I'll post a follow-up if I find
something.

"Jason Dolinger" wrote:

> Hi all,
>
> Starting to get into even messier questions now... Is it possible to
> have multiple layers of layout going on in the application? Let's say
> that I'm using a grid layout to neatly and symmetrically define a number
> of controls and elements. On top of that, I wish to randomly scattered
> some other overlayed things on top. That second layer really doesn't
> fit into the idea of a grid layout as it is somewhat irregular, what I
> really need is to manage the arrangement of those myself, which would
> lend itself to an canvas.
>
> So given that scenario, can you give a window both a grid layout and a
> canvas layout, and put different controls/visuals into the different
> layers? Or perhaps the answer is using the canvas for the base layout,
> and then nesting a full window sized grid within that canvas. Any thoughts?
>
> Thanks!
> Jason
>

My System SpecsSystem Spec
Old 01-31-2006   #3 (permalink)
Jason Dolinger
Guest


 

Re: Multiple layers or visual layout?

Thanks, that's exactly what I need (except I'm going to be creating the
second layer at runtime in response to event on the first layer).

JosephCooney wrote:
> Hi Jason
>
> It is possible to use the canvas to absolutely position items within it.
> Also child controls are rendered in the order that they appear in the markup
> (earlier controls are rendered behind ones that appear later). If your grid
> layout appears as the first child control of a top-level canvas element then
> items that come after the grid can be absolutely positioned over the top of
> the grid. Here is an example:
>
> <Window x:Class="DrawingOverGridContents.Window1"
> xmlns="http://schemas.microsoft.com/winfx/avalon/2005"
> xmlns:x="http://schemas.microsoft.com/winfx/xaml/2005"
> Title="DrawingOverGridContents"
> >

> <Canvas>
> <Grid ShowGridLines="True" Width="200" Height="200">
> <Grid.RowDefinitions>
> <RowDefinition/>
> <RowDefinition/>
> <RowDefinition/>
> </Grid.RowDefinitions>
> <Grid.ColumnDefinitions>
> <ColumnDefinition/>
> <ColumnDefinition/>
> </Grid.ColumnDefinitions>
> <TextBlock Background="Orange" Grid.Column="0" Grid.Row="0">Row0,
> Col0</TextBlock>
> <TextBlock Background="CornflowerBlue" Grid.Column="0"
> Grid.Row="1">Row1, Col0</TextBlock>
> <TextBlock Background="BlanchedAlmond" Grid.Column="0"
> Grid.Row="2">Row2, Col0</TextBlock>
> <TextBlock Background="Red" Grid.Column="1" Grid.Row="0">Row0,
> Col1</TextBlock>
> <TextBlock Background="Navy" Grid.Column="1" Grid.Row="1">Row1,
> Col1</TextBlock>
> <TextBlock Background="FireBrick" Grid.Column="1" Grid.Row="2">Row2,
> Col1</TextBlock>
> </Grid>
> <Border Canvas.Top="30" Canvas.Left="60" CornerRadius="5"
> BorderBrush="DarkGreen" BorderThickness="2">
> <TextBlock Background="Green" FontSize="32">Special!</TextBlock>
> </Border>
> </Canvas>
> </Window>
>
> I'd be a little worried about all the absolute positioning that this would
> require however, and would try and avoid it if possible. There might also be
> a way to do this all with just a grid too. I seem to remember seeing
> something in John Gossman's PDC05 talk towards the end which covered
> something like this, but I'm not 100% sure. I'll post a follow-up if I find
> something.
>
> "Jason Dolinger" wrote:
>
>
>>Hi all,
>>
>>Starting to get into even messier questions now... Is it possible to
>>have multiple layers of layout going on in the application? Let's say
>>that I'm using a grid layout to neatly and symmetrically define a number
>>of controls and elements. On top of that, I wish to randomly scattered
>>some other overlayed things on top. That second layer really doesn't
>>fit into the idea of a grid layout as it is somewhat irregular, what I
>>really need is to manage the arrangement of those myself, which would
>>lend itself to an canvas.
>>
>>So given that scenario, can you give a window both a grid layout and a
>>canvas layout, and put different controls/visuals into the different
>>layers? Or perhaps the answer is using the canvas for the base layout,
>>and then nesting a full window sized grid within that canvas. Any thoughts?
>>
>>Thanks!
>>Jason
>>

My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
2 Layers Of Encryption? Fmjc001 System Security 2 07-12-2008 07:17 AM
Visual Layout mattg08 Vista General 1 01-18-2008 10:58 AM
Multiple Microsoft Visual C++ 2005 Redistributable Installations Jim Vista General 5 10-24-2007 09:28 PM
Multiple Versions of Microsoft Visual C++ 2005 Redistributiable? Jim Vista General 1 10-24-2007 10:44 AM
Multiple layers of layout? Jason Dolinger Avalon 2 01-31-2006 06:59 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 51