How do you span columns in C#?
In silverlight, suppose you have a grid, and this grid is in 3 columns.
and you want to add a UserControl to this grid but you want it to span all three
columns. How would that C# code look like?
Grid1.Children.Add(UserControl01);
But then what?
Grid1.Children.ElementAt(1).SetValue(Grid.SetRowSpan, 2); ??

Member Avatar for Unhnd_Exception

Grid.SetColumnSpan.

In Vb but you should get the point.

Dim SpannedButton As New System.Windows.Controls.Button
   SpannedButton.HorizontalAlignment = Windows.HorizontalAlignment.Stretch
   SpannedButton.Content = "Spanned Three"

   Windows.Controls.Grid.SetColumn(SpannedButton, 0)
   Windows.Controls.Grid.SetRow(SpannedButton, 0)
   Windows.Controls.Grid.SetColumnSpan(SpannedButton, 3)

   Grid1.Children.Add(SpannedButton)

How do you span columns in C#?
In silverlight, suppose you have a grid, and this grid is in 3 columns.
and you want to add a UserControl to this grid but you want it to span all three
columns. How would that C# code look like?
Grid1.Children.Add(UserControl01);
But then what?
Grid1.Children.ElementAt(1).SetValue(Grid.SetRowSpan, 2); ??

Grid1.Children.Add(UserControl01);

Grid.SetColumnSpan(UserControl01, 3);

commented: Unhnd_Exception -2
Member Avatar for Unhnd_Exception

Whats that suppose to mean.

Did it not work? Or where you wanting it in c# not vb. The only difference is a ; in this case.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.