Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - Grid.Row Grid.Column set programatically at runtime

 
 
Old 01-10-2006   #1 (permalink)
craig kelly-soens www.XpectWorld.com


 
 

Grid.Row Grid.Column set programatically at runtime

hi,
How to programatically change the Grid.Row and Grid.Column & ColumnSpan at
runtime.

I wanted a way to make my customer selection and shopping basket
XAML frames to be vertical or horizontally configurable, depending upon how
long a product's description was.

Took a bit to find this so im posting it to help others as i didnt find
anything myself.

Assuming you only have one grid per code behind file
(which is highly possible if you make your app very modular)

<!--XAML initial state to have both vertical for short product names-->

<!-- left -->
<Label Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="1"
VerticalAlignment="Center" >Click to Add</Label>
<Frame Name="SelectionFrame" Grid.Row="1" Grid.Column="0"
Grid.ColumnSpan="1" Margin="2"></Frame>

<!-- right -->
<Label Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="1"
VerticalAlignment="Center" >Click to Remove</Label>
<Frame Name="BasketFrame" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="1"
Margin="2"></Frame>

//c# code to move it to a horizontal position

//make top horiz left selection
Grid.SetColumnSpan(SelectionFrame, 2);
Grid.SetColumn(SelectionFrame, 0);

//make bottom horiz right basket
Grid.SetColumnSpan(BasketFrame, 2);
Grid.SetColumn(BasketFrame, 0);
Grid.SetRow(BasketFrame, 2);

craig.

craig kelly-soens - Windows Vista WinFx XAML .Net Evangelist
http://www.XpectWorld.com - customised "super-easy to use" Windows Vista
based software & consultancy

My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
wpf data grid .NET General


Vista Forums 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 Ltd

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