<Pro WPF 4.5 in C#> - Note-01

本文介绍了WPF中的XAML特性,包括属性和事件、标记扩展、附加属性、元素嵌套以及特殊字符和空白处理。此外,还探讨了WPF布局哲学,如元素自适应大小、位置不使用屏幕坐标以及布局容器如何分配空间。最后,讨论了从Panel派生的布局容器和Control类,内容控制以及文本控件的功能。
摘要由CSDN通过智能技术生成



Chapter 2: XAML



Properties and Events in XAML


Markup Extensions

You may want to set a property value dynamically by binding it to a property in another control. Markup extensions can be used in nested tags or in XML attributes, which is more common. When they're used in attributes, they are always bracketed by curly braces {}.

<Button ... Foreground="{x:Static SystemColors.ActiveCaptionBrush}" >


it is equivalent to C# code in behind class:

cmdAnswer.Foreground = SystemColors.ActiveCaptionBrush;


When being used as nested properties, it becomes:

<Button ... >
	<Button.Foreground>
		<x:Static Member="SystemColors.ActiveCaptionBrush"></x:Static>
	</Button.Foreground>
</Button>


Attached Properties

Attached properties always use a two-part name in this form: DefiningType.PropertyName, like:

<TextBox ... Grid.Row="0">


Attached properties aren't really properties at all. They're translated into method calls. ...so the parser calls Grid.SetRow(), which is:

Grid.SetRow(txtQuestion, 0);


The row number is actually stored in the object that it applies to—in this case, the TextBox object.

TextBox derives from the DependencyObject base class, the DependencyObject is designed to store a virtually unlimited collection of dependency properties.

In fact, the Grid.SetRow() method is a shortcut that's equivalent to calling the DependencyObject.SetValue() method, as shown here:

txtQuestion.SetValue(Grid.Row
Microsoft's Windows Presentation Foundation (WPF) provides you with a development framework for building high-quality user experiences for the Windows operating system. It blends together rich content from a wide range of sources and allows you unparalleled access to the processing power of your Windows computer. Pro WPF 4.5 in C# provides a thorough, authoritative guide to how WPF really works. Packed with no-nonsense examples and practical advice you'll learn everything you need to know in order to use WPF in a professional setting. The book begins by building a firm foundation of elementary concepts, using your existing C# skills as a frame of reference, before moving on to discuss advanced concepts and demonstrate them in a hands-on way that emphasizes the time and effort savings that can be gained. What you’ll learn •Understand the fundamentals of WPF programming from XAML to controls and data flow. •Develop realistic application scenarios to see navigation, localization and deployment in action. •Explore the advanced user interface controls that WPF provides. •Learn to manage documents from within WPF: Text layout, printing, and document packaging are all covered. •Use graphics and multimedia to add punch to your applications Who this book is for This book is designed for developers encountering WPF for the first time in their professional lives. A working knowledge of C# and the basic architecture of .NET is helpful to follow the examples easily, but all concepts will be explained from the ground up. Table of Contents 01.Introducing WPF 02.XAML 03.Layout 04.Dependency Properties 05.Routed Events 06.Controls 07.The Application 08.Element Binding 09.Commands 10.Resources 11.Styles and Behaviors 12.Shapes, Brushes, and Transforms 13.Geometries and Drawings 14.Effects and Visuals 15.Animation Basics 16.Advanced Animation 17.Control Templates 18.Custom Elements 19.Data Binding 20.Formatting 21.Bound Data 22.Data Views 23.Lists, Trees, and Grids 24.Windows Pages and Navigation 25.Menus, Toolbars, and Ribbons 26. Sound and Video 27.3-D Drawing 28.Documents 29. Printing 30.Interacting with Windows Forms 31.Multithreading 32.The Add-in Model 33.ClickOnce Deployment ----------------------------------------------------------- Pro WPF 4th edition,喜欢的朋友请支持正版。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值