WPF recipes in C# 2008

746 390 0
WPF recipes in C# 2008

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

hướng dẫn lập trình MVVM mô hình lập trình mới từ view Binding đến model

[...]... application that contains a single System Windows.Window The window defines a single read-only CLR property that is backed by a System.Windows.DependencyProperty, referenced using a System.Windows.DependencyPropertyKey A System.Windows.Threading.DispatcherTimer is used to increment the value of the Counter property every second using System; using System.Windows; using System.Windows.Threading; namespace... 682 ■CHAPTER 13 Migrating and Windows Forms Interoperability 685 13-1 Use WPF Windows in a Windows Forms Application 686 13-2 Use WPF Controls in Windows Forms 689 13-3 Use Windows Forms in a WPF Application 693 13-4 Use Windows Forms Controls in a WPF Window 696 ■INDEX ... rich WPF desktop application Solution Create a new project with a single App.xaml file, containing the main entry point for your application 1 2 CHAPTER 1 ■ BUILDING AND DEBUGGING WPF APPLICATIONS How It Works In its simplest form, an application is defined by creating a System.Windows.Application object When creating a new Windows Application project in Visual Studio, you are given the default definition... application to creating custom properties that you can use in animations and bindings to narrowing down the debugging process of data bindings, there’s something for everyone This chapter focuses on the basics of building a rich WPF application and some methods that you can use to help ease the debugging of data bindings The recipes in this chapter describe how to: • Create a standard WPF application (recipe... they are done with The Code using using using using System; System.ComponentModel; System.Windows; System.Windows.Controls; namespace Recipe_01_06 { /// /// Interaction logic for Window1.xaml /// public partial class Window1 : Window { public Window1() { InitializeComponent(); } 19 20 CHAPTER 1 ■ BUILDING AND DEBUGGING WPF APPLICATIONS private void Window1_Loaded(object sender,... result in a runtime exception The Code The following code demonstrates a simple XAML file that defines a System.Windows.Window The window contains a System.Windows.Controls.Viewbox, which is used to display a System Windows.Controls.TextBlock The value of the TextBlock’s Text property is bound to a custom dependency property defined in the window’s code-behind file 13 14 CHAPTER 1 ■ BUILDING AND DEBUGGING... The example comprises the following: the App.xaml file defines the markup for a System.Windows.Application object, with a build action of ApplicationDefinition; the App xaml.cs, which contains the Application object’s code-behind; the Window1.xaml file, which contains the markup for the application’s main window; and Window1.xaml.cs, which contains the window’s code-behind This is the code for App.xaml:... Problem You need to add a property to a System.Windows.DependencyObject that provides support for any or all of the following: • Data bindings 7 8 CHAPTER 1 ■ BUILDING AND DEBUGGING WPF APPLICATIONS • Animation • Setting with a dynamic resource reference • Automatically inheriting a property value from a super-class • Setting in a style • Using property value inheritance (see recipe 1-9) • Notification... System.Windows.Controls.Button In the window’s code-behind, the metadata for the window’s DataContextProperty is overridden The overriding data specifies a new default value and registers a property-changed callback The first code block defines the window’s markup file, and the second defines the window’s code-behind

Ngày đăng: 26/04/2014, 11:07

Mục lục

  • cover-large.tif

  • front-matter.pdf

  • fulltext.pdf

  • fulltext_2.pdf

  • fulltext_3.pdf

  • fulltext_4.pdf

  • fulltext_5.pdf

  • fulltext_6.pdf

  • fulltext_7.pdf

  • fulltext_8.pdf

  • fulltext_9.pdf

  • fulltext_10.pdf

  • fulltext_11.pdf

  • fulltext_12.pdf

  • fulltext_13.pdf

  • back-matter.pdf

Tài liệu cùng người dùng

Tài liệu liên quan