Blogs

The One With

Silverlight and the layout management. (Grid, Canvas, StackPanel or ?)

     

If you have done any Silverlight development, then you are familiar with the Canvas, the Grid and the StackPanel.

All 3 containers are unique in their own way. But they all have some limitations/drawbacks. Let's see:

1: The Canvas:

<Canvas Background="Blue">
   <TextBlock Height="50" Width="50" Canvas.Left="15" Canvas.Top="15" />
</Canvas>

I don't want to pixelate my items.

2: The StackPanel: 

<StackPanel>

   <TextBlock Height="50" Width="50" />
   <TextBlock Height="50" Width="50" />  

</StackPanel>

Just not rich enough to do any complex layouts.

3: The Grid:

<Grid Background="Silver">
   <Grid.ColumnDefinitions>
       <ColumnDefinition Width="*2" />
       <ColumnDefinition Width="*1" />
   </Grid.ColumnDefinitions>
   <Grid.RowDefinitions>
       <RowDefinition Height="50" />
       <RowDefinition Height="100" />
   </Grid.RowDefinitions>

   <TextBlock Height="50" Width="50" Grid.Row="1" Grid.Column="1"/>

</Grid>

Yes, I can define a very complex layout using the Grid. But I am still required to place my items inside "a" cell by specifying

the Grid.Row and Grid.Column attributes on each individual item. I also need to decide, how may rows and columns my page has.

This just does not feel natural.

To address this, Developer Express is working on a special LayoutControl container that will eliminate these hassles. All you have to do is specify where you want

your items placed. Left, Right, Top or Bottom.

<DockedLayoutControl x:Name="layoutItems" DockedLayoutControl.Dock="Client">
            <TextBlock Text="My Top Text" DockedLayoutControl.Dock="Left"/>
            <TextBlock Text="My Bottom Text" DockedLayoutControl.Dock="Bottom"/>
</DockedLayoutControl>

Here is a screen shot of a layout done using a DockedLayoutControl.

SS

Next time, we will look at another layout control that we are working on, called the FlowLayoutControl.

Published Jun 05 2008, 01:02 AM by Azret Botash (DevExpress)
Filed under:
Technorati tags: Silverlight
Bookmark and Share

Comments

 

Rory Becker - DevExpress said:

So how do I specify...

|----|

|     |

|----|

rather than

------

|     |

|     |

------

Please excuse poor ascii art.

June 5, 2008 6:14 AM
 

gk said:

Will i be able to drag and drop controls from a toolbox (like textblock) into the layout manager and  create custom layouts which can be saved and restored later on? Something like an on line  visual studio IDE for layouts.

June 5, 2008 6:39 AM
 

Evgeniy Meyke said:

btw, Area 51 is up again

demos.devexpress.com/silverlight

June 5, 2008 7:12 AM
 

Ben Hayat said:

Azret, it was great talking to you yesterday. Yes, you picked quickly on my points about the problems that I've seen with the three panels from MSFT. And I hope we can overcome those with your new layouts.

June 5, 2008 8:58 AM
 

James said:

Whoohoo!

Does this mean we're going to get a full XtraLayout eventually?

That would be NICE.

June 5, 2008 9:07 AM
 

Ben Hayat said:

>>btw, Area 51 is up again

demos.devexpress.com/silverlight<<

This is odd, trying the link, asks me to install "Silverlight 2" plugin, where I have SL2 beta 1 already on this machine. I wonder if Vlad compiled it with Beta 2?

June 5, 2008 9:48 AM
 

Azret Botash (DevExpress) said:

Hi Ben, Area 51 runs on Beta 2. That is why I have not posted a link to it. I will make a post with a link to SL B2 download as soon Microsoft makes it available.

June 5, 2008 10:24 AM
 

Azret Botash (DevExpress) said:

Rory: I will cover the various layouts in the upcoming blogs.

James: :)

June 5, 2008 10:26 AM
 

Evgeniy Meyke said:

>>Hi Ben, Area 51 runs on Beta 2. That is why I have not posted a link to it. I will make a post with a link to SL B2 download as soon Microsoft makes it available.

strange... i have 2.0.30523.4 installed

June 5, 2008 11:13 AM
 

Robert Fuchs said:

> strange... i have 2.0.30523.4 installed

The same here...

June 5, 2008 11:48 AM
 

Vlad Filyakov (DevExpress) said:

2.0.30523.4 is SL2 Beta2 :-)

June 5, 2008 1:24 PM
 

Evgeniy Meyke said:

and how did we manage to get it?

June 5, 2008 1:32 PM
 

Vlad Filyakov (DevExpress) said:

I should ask you guys - how did you get it :-)

Did you install it after opening the AgLayoutControl demo?

June 5, 2008 3:01 PM
 

Evgeniy Meyke said:

I think this is how it happened...

There was "get sl" logo or whatever which got me wondering as i thought i had it. I installed and then i couldnt open the page for sometime - showing message at the top of the screen that silverlight app could not load. And then it worked...

June 5, 2008 3:06 PM
 

Vlad Filyakov (DevExpress) said:

2 Rory Becker:

Actually you can see this shown on the image Azret posted: take a look at items 3, 4 and 5 - left and right docked items have priority over the top docked item. Is this what you want?

In the DockedLayoutControl the order of the items is important, just like in the WPF's DockPanel. Each item gets layouted in the remaining space. And each already layouted item eats the remaining space, reducing it for the items coming after it.

June 5, 2008 3:07 PM
 

Ben Hayat said:

I thought as of version 2, the plugin does not ask you to download and install, if you already have the plugin from the previous version. It should automatically update itself. I read that from one of the MSFT employees in one blog!

@Vlad: When do you think we can beta the layout? And secondly, can you write a blog about what features are going to be supported and their benefits against SP, Grid and Canvas? The reason for this question, is not a marketing answer, but which areas of my app I should changed from MSFT stuff to your layout?

June 5, 2008 3:44 PM
 

Vlad Filyakov (DevExpress) said:

2 Ben:

SL will update itself to next major version (1.0 to 2) or to a new minor build. It, however, cannot update itself from Beta1 to Beta2 - they are not compatible.

Regarding LC: there is no plan for beta for now. Main reason - design-time support for SL 2 from Blend and VS. So we have to wait here for now.

June 5, 2008 7:42 PM
 

Ben Hayat said:

Thanks Vlad for both answers. Yes, the design time support seems to hunt any Visual component developer, even during Borland days ;-)

>>however, cannot update itself from Beta1 to Beta2<<

Hopefully, this will not be an issue between Beta 2 and RTW, since there will be ton of people downloading Beta 2 plugin for Olympics and then after Olympics is when RTW will be released!

June 5, 2008 8:47 PM
 

Ben Hayat said:

Vlad, now that I have your attention, one question:

Let's say I'm using your layout control and I've placed other controls as part of it's content. Now the end user resizes the browser. a) Does the layout resize itself b) and if yes, will it also resize (shrink/expand) it's contents, i.e. the controls that I have put in? Or if  I have put images in the layout, will the images gets resized accordingly?

Thanks!

June 5, 2008 8:54 PM
 

John Harrison said:

what's a TexhBlock?

June 6, 2008 4:04 AM
 

Mehul Harry (DevExpress) said:

Hi John,

That was just a mistype. It's should say TextBlock. Corrected, thanks.

June 6, 2008 11:50 AM
 

Vlad Filyakov (DevExpress) said:

2 Ben:

Not sure how Beta1 to Beta2 update will work - maybe it will be smooth, but applications written for Beta1 won't work with Beta2.

LC is just another Panel, so if a regular control will be resized in your situation, then LC will resize too. LC children will be resized accordingly to their HorizontalAlignment and VerticalAlignment properties, just like in the StackPanel or Grid.

June 6, 2008 12:11 PM
 

Azret Botash (DevExpress) said:

Silverlight 2 Beta 2 can now be downloaded from:

silverlight.net/GetStarted

June 9, 2008 1:26 PM
 

Chris Vickerson said:

Hi there,

fyi,

demos.devexpress.com/silverlight is broken in Firefox but not IE, for me.

June 9, 2008 1:55 PM
 

Azret Botash (DevExpress) said:

Chris, can you please try again?

June 9, 2008 3:39 PM
 

Ben Hayat said:

>>Chris, can you please try again?<<

This thing is fast. You would appreciate his work, once you start hitting your head against the wall, because after 10 hours of work, you hit the brick wall with StackPanel Grid!

Even in version 1.1, his demo was the fastest I had seen!

June 9, 2008 4:30 PM
 

Chris Vickerson said:

Looks fantastic now! - silverlight is the future, no doubt about it.  The only thing missing for me is a really good editor with complex formatting options.

Thanks for your hard work!

June 9, 2008 10:38 PM
More from DevExpress
Live Chat
Have a pre-sales question?
Need assistance with your evaluation?
We are here to help.
Chat is one of the many ways you can contact members of the DevExpress Team. We are available Monday-Friday between 8:30am and 5:00pm Pacific Time.
If you need additional product information, require pre-sales assistance, or want help with your order, write to us at info@devexpress.com or call us at
+1 (818) 844-3383.