[WPF] XAML(Extensible Application Markup Language)

XAML이 WPF의 컨트롤과 컨트롤의 레이아웃을 정의한다
디자이너이면 Microsoft Expression Blend을 이용하게 될 것이고, 개발자면 비주얼 스튜디오를 사용한다

비주얼 스튜디오에서 XAML 컴파일을 하게 되면 BAML(바이너리)로 변환되게 된다.

** top-level element
• Window
• Page (which is similar to Window, but used for navigable applications)
• Application (which defines application resources and startup settings)


** The Code-Behind Class
<Window x:Class="WindowsApplication1.Window1"

namespace WindowsApplication1
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
    public Window1()
    {
        InitializeComponent();
    }
}
}

** Attached Properties- DefiningType.PropertyName
They’re actually translated into method
calls.

example)
<TextBox ... Grid.Row="0">
[Place question here.]
</TextBox>

--> Grid.SetRow(txtQuestion, 0);

** Special Characters andWhitespace
<Button ... >
<Click Me>
</Button>
--> should be
<Button ... >
&lt;Click Me&gt;
</Button>

<TextBox Name="txtQuestion" xml:space="preserve" ...>
[There is a lot of space inside these quotation marks " ".]
</TextBox>


** Events
<Button ... Click="cmdAnswer_Click">


** Using Types from Other Namespaces
xmlns:Prefix="clr-namespace:Namespace;assembly=AssemblyName"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:local="clr-namespace:MyNamespace"

<local:MyObject ...></local:MyObject>

XAML doesn’t support parameterized constructors, and all the elements
in WPF elements include a no-argument constructor.

<Window x:Class="WindowsApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
Width="300" Height="300"
>
<ListBox>
<ListBoxItem>
<sys:DateTime>10/13/2010 4:30 PM</sys:DateTime>
</ListBoxItem>
<ListBoxItem>
<sys:DateTime>10/29/2010 12:30 PM</sys:DateTime>
</ListBoxItem>
<ListBoxItem>
<sys:DateTime>10/30/2010 2:30 PM</sys:DateTime>
</ListBoxItem>
</ListBox>
</Window>

** Loading and Compiling XAML