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 - Populating a grid programmatically

 
 
Old 01-31-2006   #1 (permalink)
Griff


 
 

Populating a grid programmatically

I'm generating on onscreen keyboard (for an industrial touchscreen app) and
it should clearly be based on a grid with buttons.

It is crying out to be populated from code, not markup, but I cannot find
any examples or documentation regarding how to add content to a specific cell
in the grid layout, with specific rowspan etc.

Any weblinks or other hints much appreciated.

--
Griff
(trying to make an industrial UI with XAML/WPF/c#)

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


 
 

RE: Populating a grid programmatically

OK, the answer was under my nose in this forum !

For anyone interested.

(assuming x:Name="myGrid" in markup)

// add rows to grid (it's the same deal for columns too)
for (int row=0;row < numRows; row++)
{
myGrid=RowDefinitions.Add(new RowDefinition());
}

(I'd be interested to see if there is a slicker way of doing this bit. )


// Stick a control in intended location

b = new Button();

myGrid.Children.Add(b);
Grid.SetRow(b,1); // 2nd row
Grid.SetColumn(b,3); // 4th column
Grid.SetColumnSpan(b,2);

b.Style = (Style)FindResource("myButtonStyle"); // defined in MyApp.xaml


As with all these things, seems obvious afterwards

--
Griff
(trying to make an industrial UI with XAML/WPF/c#)


"Griff" wrote:

> I'm generating on onscreen keyboard (for an industrial touchscreen app) and
> it should clearly be based on a grid with buttons.
>
> It is crying out to be populated from code, not markup, but I cannot find
> any examples or documentation regarding how to add content to a specific cell
> in the grid layout, with specific rowspan etc.
>
> Any weblinks or other hints much appreciated.
>
> --
> Griff
> (trying to make an industrial UI with XAML/WPF/c#)

My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
IM address import not populating in WLM Live Messenger
Populating ComboBox VB Script
Populating a combo box PowerShell
Populating dataset crashes app without error message .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