using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace _IT_tutorial2_1
{
/// <summary>
/// XAMLを使わずCLRでコントロール等を配置
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.Content = new Grid //メインウインドウに要素を足す場合、Contentプロパティに対して操作を行う
{
Children =
{
new StackPanel //GridやStackパネルに対してはChildrenプロパティを使う(このチルドレンというプロパティはXAMLの構文自体がその機能を持っている為存在しない点に注目)
{
Children =
{
new Menu { Items = { new MenuItem { Header = "メニュー" } } },
new Button { Content = "ボタン" },
new CheckBox { Content = "チェックボックス" },
new ComboBox { Items = { "コンボボックス" }, SelectedIndex = 0 },
new RadioButton { Content = "ラジオボタン" },
new Slider(),
new ListBox { Items = {"リストボックス項目1","リストボックス項目2",}}
}
}
}
};
}
}
}
-------------------------------------------------------------------------
・Content
・Source
・Items
・ItemSource
・DataContext
・Children
すべて良く似ているようで違うものなのでそれを意識すると良い
最終更新:2012年10月09日 02:13