본문 바로가기

카테고리 없음

프로그래밍 C# (7)

반응형

What is XAML?

XAML, which stands for eXtensible Application Markup Language, is

Microsoft's variant of XML for describing a GUI.

WinForms에서는 GUI를 C#으로 표현(VS의 Designer에서 작업)

XAML을 이용하면 GUI를 쉽게 만들고 수정할 수 있다

Essential part of WPF.

Whether you're creating a Window or a Page, it will consist of a XAML

document and a CodeBehind file, which together creates the Window/Page.

The XAML file describes the interface with all its elements, while the

CodeBehind handles all the events and has access to manipulate with the XAML controls.

http://www.wpf-tutorial.com/xaml/what-is-xaml/

Grid

가장 많이 사용되는 컨테이너

<Grid>는 내부에 있는 UI 요소를 가득차게 표시

StackPanel

컨트롤을 쌓아두는 레이아웃

Orientation 속성

Vertical, Horizontal 지정

Login

Title="MainWindow" Height="350" Width="400">

<Grid Background="LightSteelBlue">

<StackPanel Margin="40" Background="AliceBlue">

<TextBlock Text="로그인"

HorizontalAlignment="Center"

FontSize="18"

FontWeight="Bold"

Padding="10"/>

<StackPanel Orientation="Horizontal"

HorizontalAlignment="Center"

Margin="20 20 20 10">

<TextBlock Text="Id:"

HorizontalAlignment="Right"

FontSize="18"

MinWidth="100"/>

<TextBox x:Name="txtId" FontSize="18" MinWidth="150"/>

</StackPanel>

<StackPanel Orientation="Horizontal"

HorizontalAlignment="Center"

Margin="20 10 20 10">

<TextBlock Text="Password:"

HorizontalAlignment="Right"

FontSize="18"

MinWidth="100"/>

<PasswordBox x:Name="txtPass" FontSize="18" MinWidth="150"/>

</StackPanel>

<StackPanel Orientation="Horizontal"

HorizontalAlignment="Center"

Margin="20 10 20 20">

<TextBlock Text=""

HorizontalAlignment="Right"

FontSize="18"

MinWidth="100"/>

<Button x:Name="btnLogin"

Click="btnLogin_Click"

Content="Login" FontSize="18" MinWidth="150"/>

</StackPanel>

</StackPanel>

</Grid>

</Window>

DockPanel

Title="MainWindow" Height="550" Width="300">

<StackPanel MinWidth="250">

<StackPanel Margin="20" Orientation="Horizontal"

HorizontalAlignment="Center">

<Button Width="50" Height="50" Margin="5">

<StackPanel>

<Rectangle Fill="Red" Width="25" Height="25"/>

<TextBlock

HorizontalAlignment="Center">Red</TextBlock>

</StackPanel>

</Button>

<Button Width="50" Height="50" Margin="5">

<StackPanel>

<Rectangle Fill="Green" Width="25" Height="25"/>

<TextBlock

HorizontalAlignment="Center">Green</TextBlock>

</StackPanel>

</Button>

<Button Width="50" Height="50" Margin="5">

<StackPanel>

<Rectangle Fill="Blue" Width="25" Height="25"/>

<TextBlock

HorizontalAlignment="Center">Blue</TextBlock>

</StackPanel>

</Button>

</StackPanel>

<Button FontWeight="Bold" FontSize="20"

Margin="30" Height="100" MinWidth="200">

<WrapPanel>

<TextBlock Foreground="Blue">Multi</TextBlock>

<TextBlock Foreground="Red">Color</TextBlock>

<TextBlock>Button</TextBlock>

</WrapPanel>

</Button>

<UniformGrid Height="200" Width="200">

<Rectangle Fill="Red"/>

<Rectangle Fill="Black"/>

<Rectangle Fill="Black"/>

<Rectangle Fill="Red"/>

</UniformGrid>

</StackPanel>

</Window>

UniformGrid

<Window x:Class="W004_UniformGrid.MainWindow"

Title="UniformGrid" Height="450" Width="450">

<UniformGrid>

<Rectangle Fill="Black"/>

<Rectangle Fill="Red"/>

<Rectangle Fill="Red"/>

<Rectangle Fill="Black"/>

</UniformGrid>

</Window>

반응형