Reputation: 897
I read that I can use Silverlight Toolkit to make columns. But how can I do it with C# code, not with XAML? (in my class)
For example:
<toolkit:WrapPanel Orientation="Vertical" Height="400">
<Button Content="A" BorderBrush="Aqua" />
<Button Content="B" BorderBrush="CadetBlue" />
<Button Content="C" BorderBrush="DarkMagenta" />
<Button Content="D" BorderBrush="Fuchsia" />
<Button Content="F" BorderBrush="LightBlue" />
<Button Content="G" BorderBrush="Orange" />
</toolkit:WrapPanel>
But how can I do it with C# function?
Upvotes: 1
Views: 177
Reputation: 65566
Here's how you write the same thing in C#
var wp = new WrapPanel
{
Orientation = System.Windows.Controls.Orientation.Vertical,
Height = 400
};
wp.Children.Add(new Button { Content = "A", BorderBrush = new SolidColorBrush(Colors.Cyan) }); // Cyan is the same as Aqua
wp.Children.Add(new Button { Content = "B", BorderBrush = new SolidColorBrush(Color.FromArgb(255, 95, 158, 160)) }); // CadetBlue
wp.Children.Add(new Button { Content = "C", BorderBrush = new SolidColorBrush(Color.FromArgb(255, 139, 0, 139)) }); // DarkMagenta
wp.Children.Add(new Button { Content = "D", BorderBrush = new SolidColorBrush(Colors.Magenta) }); // Fuschia is the same as Magenta
wp.Children.Add(new Button { Content = "F", BorderBrush = new SolidColorBrush(Color.FromArgb(255, 173, 216, 230)) }); // LightBlue
wp.Children.Add(new Button { Content = "G", BorderBrush = new SolidColorBrush(Colors.Orange) });
this.LayoutRoot.Children.Add(wp);
Upvotes: 3