|
|
|
- 버튼 생성
|
|
|
|
|
|
|
|
```csharp
|
|
|
|
<Button Height="80" Width="150">Test</Button>
|
|
|
|
|
|
|
|
Button button = new Button() { Height = 80, Width = 150, Content = "Test" };
|
|
|
|
parentControl.Add(button);
|
|
|
|
```
|
|
|
|
|
|
|
|
- 버튼 여백
|
|
|
|
|
|
|
|
```csharp
|
|
|
|
<Button Margin="1, 2"/>
|
|
|
|
|
|
|
|
Button button = new Button() { Margin = new Thickness(1, 2, 1, 2) };
|
|
|
|
```
|
|
|
|
|
|
|
|
- Label 생성 및 바인딩
|
|
|
|
|
|
|
|
```csharp
|
|
|
|
<Label MaxWidth={Binding ActualWidth, Source={Binding ElementName=Container}}>
|
|
|
|
|
|
|
|
Label label = new Label();
|
|
|
|
label.SetBinding(
|
|
|
|
Label.MaxWidthProperty,
|
|
|
|
new Binding("ActualWidth") { Source = Container }
|
|
|
|
);
|
|
|
|
```
|
|
|
|
|
|
|
|
- Label 생성 및 Grid에 배치
|
|
|
|
|
|
|
|
```csharp
|
|
|
|
<Label Grid.Column="1"/>
|
|
|
|
Label label = new Label();
|
|
|
|
Grid.SetColumn(label, 1);
|
|
|
|
```
|
|
|
|
|
|
|
|
- 버튼 생성 및 이벤트 핸들링
|
|
|
|
|
|
|
|
```csharp
|
|
|
|
public void btnAddMore_Click(object sender, RoutedEventArgs e)
|
|
|
|
{
|
|
|
|
System.Windows.Controls.Button newBtn = new Button();
|
|
|
|
newBtn.Content = “A New Button”;
|
|
|
|
newBtn.Click += new RoutedEventHandler(newBtn_Click);
|
|
|
|
splMain.Children.Add(newBtn);
|
|
|
|
|
|
|
|
System.Windows.Controls.Label newLbl = new Label();
|
|
|
|
|
|
|
|
newLbl.Content = “Hi Mom!”;
|
|
|
|
splMain.Children.Add(newLbl);
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|