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

Grid.Row Grid.Column set programatically at runtime

Closed Thread
 
Thread Tools Display Modes
Old 01-10-2006   #1 (permalink)
craig kelly-soens www.XpectWorld.com
Guest


 

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
Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Grid question Yoavo Avalon 1 09-17-2007 10:14 AM
WPF Grid? john Avalon 8 11-20-2006 12:10 PM
WPF Grid? john Avalon 0 11-19-2006 12:55 PM
Bind to a particular row and column of a dynamic grid? Phillip M. Hoff Avalon 0 06-20-2006 12:05 AM
EXCEL like grid lcantelmo@gmail.com Avalon 3 01-10-2006 03:54 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