Routed events come in the following three flavors

이미지
Direct events These are like ordinary .NET events. They originate in one element and don’t pass to any other. For example, MouseEnter (which fires when the mouse pointer moves over an element) is a direct event. Bubbling events These events travel up the containment hierarchy. For example, MouseDown is a bubbling event. It’s raised first by the element that is clicked. Next, it’s raised by that element’s parent, then by thatelement’s parent, and so on, until WPF reaches the top of the element tree. Tunneling events These events travel down the containment hierarchy. They give you the chance to preview (and possibly stop) an event before it reaches the appropriate control. For example, PreviewKeyDown allows you to intercept a key press, first at the window level and then in increasingly more-specific containers until you reach the element that had focus when the key was pressed.  Tunneling events are useful if you need to perform some preprocessing that acts on ...

Which layout control is appropriate?

You can create almost any interface by using nested Grid containers. (One exception is wrapped rows or columns that use the WrapPanel.) However, when you’re dealing with small sections of user interface or laying out a small number of elements, it’s often simpler to use the more specialized StackPanel and DockPanel containers. A good rule of thumb is to use smaller layout containers such as the StackPanel for one-off layout tasks, such as arranging a group of buttons. On the other hand, if you need to apply a consistent structure to more than one area of your window, the Grid is an indispensable tool for standardizing your layout.

A few key principles when arranging elements.

Elements (such as controls) should not be explicitly sized. Instead, they grow to fit their content. For example, a button expands as you add more text. You can limit controls to acceptable sizes by setting a maximum and minimum size. Elements do not indicate their position with screen coordinates. Instead, they are arranged by their container based on their size, order, and (optionally) other information that’s specific to the layout container. If you need to add whitespace between elements, you use the Margin property. Layout containers “share” the available space among their children.They attempt to give each element its preferred size (based on its content) if the space is available. They can also distribute extra space to one or more children. Layout containers can be nested.A typical user interface begins with the Grid, WPF’s most capable container, and contains other layout containers that arrange smaller groups of elements, such as captioned text boxes, items in a list, ic...

The Best Books about WPF

WPF 4.5 Unleashed by Adam Nathan (Aug 9, 2013) Pro WPF 4.5 in C#: Windows Presentation Foundation in .NET 4.5 by Matthew MacDonald (Nov 20, 2012)

매우 실용적인 XAML 정의

XAML (short for Extensible Application Markup) is  a markup language used to instantiate .NET objects. 오~~~. 이 얼마나 깔끔한 설명인가. You need to understand rules: Every element in a XAML document maps to an instance of a .NET class. The name of the element matches the name of the class exactly. For example, the element <Button instructs WPF to create a Button object. As with any XML document, you can nest one element inside another. As you’ll see, XAML gives every class the flexibility to decide how it handles this situation. However, nesting is usually a way to express containment—in other words, if you find a Button element inside a Grid element, your user interface probably includes a grid that contains a button inside. You can set the properties of each class through attributes. However, in some situations, an attribute isn’t powerful enough to handle the job. In these cases, you’ll use nested tags with a special syntax.

디자인 타임에 파일 생성하기.

Design-Time Code Generation by using T4 Text Templates 주로 소스 코드 파일을 생성하는데  쓰이겠지.

런타임에 문자와 같은 리소스 생성.

Run-Time Text Generation with T4 Text Templates 런타임에 매우 큰 문자열과 같은 리소스를 동적으로 생성해야 할 경우, 리소스 생성을 소스 파일에서 할 수도 있지만, T4 Text Template을 이용하면 소스에서 분리할 수 있다.