I saw the light Alternative Grid Layout for Silverlight suggestion - Alexey Zakharov's Blog

Alternative Grid Layout for Silverlight suggestion

I've proposed a suggestion to create alternative grid layout for Silverlight. Please vote for it if also faced the same problems.

As i write before current Silverlight Grid Layout breakes best practices of HTML and Adobe Flex Grid layouts. Current defention based approach have following disadvantages that makes xaml coding very hard:

1. It is very hard to create new row. In that case you should rewrite
all Grid.Row and Grid.Columns for all rows inserted below.
2. Defenitions are static by their nature and because of it, it is
impossible to use grid for dynamic forms. Currently even in toolkit DataForm
Microsoft is using StackPanel. But StackPanel is not designed for multi
column layout that have dataform.
3. It is impossible to use Grid as ItemsPanel for ItemsControl

Here is a sample code of AdobeFlex datagrid, which incorporates best
practices of HTML.

<mx:Grid id="myGrid">

       <!-- Define Row 1. -->
       <mx:GridRow id="row1">
           <!-- Define the first cell of Row 1. -->
           <mx:GridItem>
               <mx:Button label="Button 1"/>
           </mx:GridItem>
           <!-- Define the second cell of Row 1. -->
           <mx:GridItem>
               <mx:Button label="2"/>
           </mx:GridItem>
           <!-- Define the third cell of Row 1. -->
           <mx:GridItem>
               <mx:Button label="Button 3"/>
           </mx:GridItem>
       </mx:GridRow>

       <!-- Define Row 2. -->
       <mx:GridRow id="row2">
           <!-- Define a single cell to span three columns of Row 2. -->
           <mx:GridItem colSpan="3" horizontalAlign="center">
               <mx:Button label="Long-Named Button 4"/>
           </mx:GridItem>
       </mx:GridRow>

       <!-- Define Row 3. -->
       <mx:GridRow id="row3">
           <!-- Define an empty first cell of Row 3. -->
           <mx:GridItem/>
           <!-- Define a cell to span columns 2 and 3 of Row 3. -->
           <mx:GridItem colSpan="2" horizontalAlign="center">
               <mx:Button label="Button 5"/>
           </mx:GridItem>
       </mx:GridRow>

   </mx:Grid>

kick it on DotNetKicks.com
Published Tuesday, April 20, 2010 4:21 PM by brainbox
Filed under: ,

Comments

# re: Alternative Grid Layout for Silverlight suggestion

Tuesday, April 20, 2010 12:57 PM by Eugen

I completely agree with you Alexey, they HTML way of the grid if very good one.

Last time I had a grid with 15 rows, it was a pain to add new one somewhere at the beginning :)

# re: Alternative Grid Layout for Silverlight suggestion

Tuesday, April 20, 2010 2:08 PM by _ivan

yep, agree!

# re: Alternative Grid Layout for Silverlight suggestion

Wednesday, April 21, 2010 5:50 AM by Stefaan Rillaert

Great initiative Alexey, you touch a sore spot here. Can't wait to have something like the flex grid in Silverlight and use that grid as an ItemsPanel.

Cheers, Stefaan

# re: Alternative Grid Layout for Silverlight suggestion

Wednesday, April 21, 2010 9:36 AM by brainbox

Yes. ItemsControl should work perfectly with it.

# Alternative Grid Layout for Silverlight suggestion

Wednesday, April 21, 2010 10:14 AM by DotNetKicks.com

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# re: Alternative Grid Layout for Silverlight suggestion

Thursday, April 22, 2010 1:16 AM by Anonymous

I think you are trying to use the grid to do things that it wasn't designed to do if you have 15 rows in your UI or if you need to add new rows dynamically. The grid is for layout and not for displaying data. Use ItemsControl, ListBox with styles and templates.

# re: Alternative Grid Layout for Silverlight suggestion

Saturday, July 17, 2010 4:54 PM by Vikas Amin ( Credit Suisse )

you are right, it feel like hell when business need you to insert something inbetween row's

Leave a Comment

(required) 
(required) 
(optional)
(required)