2012-03-09 9 views
1

Silverlight Toolkitを使用して列を作成できます。 しかし、XAMLではなくC#コードでどうすればいいですか?例えばWindows Phone 7の列

(私のクラスで):

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

しかし、私はC#の機能とそれをどのように行うことができますか?

+0

列を同じことを書く方法ですか?いくつかのUIの例を描き、あなたの質問に絵を追加する必要があります。なぜなら、実際に何を望んでいるのかわからないからです。 – ken2k

答えて

3

は、ここでは、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); 
+0

ありがとう!しかし、別の質問です: "LayoutRoot"が明確でない場合は、 "wp"を追加するために何ができますか? –

+0

PhoneApplicationPageクラス(MainPage)を使用しているので、Contentプロパティをwpに設定できます。 –