11/27/2018 7:24 PM Тренинг Введение в разработку приложений на Windows Presentation Foundation Занятие 5 Элементы управления Роман Здебский rzdebski@microsoft.com.

Slides:



Advertisements
Similar presentations
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Advertisements

© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Feature: Identity Management - Login © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
© 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Feature: Reprint Outstanding Transactions Report © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product.
Feature: Purchase Requisitions - Requester © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
MIX 09 4/15/ :14 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.

Co- location Mass Market Managed Hosting ISV Hosting.
Windows 7 Training Microsoft Confidential. Windows ® 7 Compatibility Version Checking.
Multitenant Model Request/Response General Model.
Feature: Purchase Order Prepayments II © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
Announcing Demo Announcing.
Feature: OLE Notes Migration Utility
Feature: Web Client Keyboard Shortcuts © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
Feature: SmartList Usability Enhancements © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
Session 1.
Built by Developers for Developers…. © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
 Rico Mariani Architect Microsoft Corporation.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Feature: Assign an Item to Multiple Sites © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Feature: Print Remaining Documents © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.
Connect with life Connect with life
NEXT: Overview – Sharing skills & code.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Feature: Document Attachment –Replace OLE Notes © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product.
Feature: Suggested Item Enhancements – Sales Script and Additional Information © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows.
Feature: Customer Combiner and Modifier © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
Feature: Employee Self Service Timecard Entry © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
Ian Ellison-Taylor General Manager Microsoft Corporation PC27.
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.
demo Instance AInstance B Read “7” Write “8”

customer.
demo © 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
demo Demo.
demo QueryForeign KeyInstance /sm:body()/x:Order/x:Delivery/y:TrackingId1Z
Feature: Suggested Item Enhancements – Analysis and Assignment © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and.
projekt202 © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
The CLR CoreCLRCoreCLR © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product.
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.

IoCompleteRequest (Irp);... p = NULL; …f(p);
Ctrl-K, X Ctrl-K, S
MIX 09 4/17/2018 4:41 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Возможности Excel 2010, о которых следует знать
Title of Presentation 11/22/2018 3:34 PM
Baseline: How Are We Doing Now?
XAML Deep Dive for Windows & Windows Phone Apps Jump Start
Title of Presentation 12/2/2018 3:48 PM
1/3/2019 1:21 PM © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Silverlight Debugging
8/04/2019 9:13 PM © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
4/27/17, Bell #8 What amount of net pay has been earned this period?
Виктор Хаджийски Катедра “Металургия на желязото и металолеене”
WINDOWS AZURE A LAP AROUND PLATFORM THE Steve Marx
PENSACOLA ENERGY WORK PLAN OCTOBER 10, 2016
Title of Presentation 5/12/ :53 PM
Шитманов Дархан Қаражанұлы Тарих пәнінің
Title of Presentation 5/24/2019 1:26 PM
5/24/2019 6:44 PM 1/8/18 Bell #10 In a world governed by the gods, is there any room for human will? Do human choices make a difference? EXPLAIN © 2007.
日本初公開!? Vista の新機能を実演 とっちゃん わんくま同盟 7/23/2019 9:09 AM
Title of Presentation 7/24/2019 8:53 PM
5/6/19, Bell #6 12/11/2019 8:26 PM Explain the relationship between this picture and the events that took place in Chapter 7 in Animal Farm. © 2007 Microsoft.
Presentation transcript:

11/27/2018 7:24 PM Тренинг Введение в разработку приложений на Windows Presentation Foundation Занятие 5 Элементы управления Роман Здебский rzdebski@microsoft.com http://blogs.msdn.com/roman © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION. 1

Содержание Элементы управления Шаблоны Стили Произвольные элементы управления

Элементы управления 11/27/2018 7:24 PM © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Элементы управления Объектная модель WPF Visual UIElement FrameworkElement Control Базовые классы Control Что на панели инструментов? Новые Элементы управления

FrameworkContentElement Объектная модель WPF DispatcherObject Dependency Object Decorator Panel Shape FrameworkContentElement ContentElement Visual3D Freezable Animatable Visual UIElement FrameworkElement Control

Visual Обеспечивает: Напоминает Win32 handle концепцию (HWND) Рендеринг Hit testing Clipping (Обрезание краев) Трансформации Вычисление границ Напоминает Win32 handle концепцию (HWND) Visual UIElement FrameworkElement Control

UIElement Обеспечивает: События ввода пользователя Маршрут. события (routed events) Маршрут. команды (routed commands) Анимации BeginAnimation Размеры и позиционирование Measure Arrange DesiredSize Visual UIElement FrameworkElement Control

FrameworkElement Обеспечивает: Систему метаданных свойств Дополнительные свойства расположения Стили Storyboards Триггеры Visual UIElement FrameworkElement Control

Control Обеспечивает: Поддержку control templates (шаблонов) Dependency properties для использования в control templates (шаблонах) Visual UIElement FrameworkElement Control

Базовые классы Control FrameworkElement Control ContentControl ItemsControl

Что на панели инструментов? ItemsControl HeaderedItemsControl MenuItem ToolBar TreeViewItem MenuBase ContextMenu Menu Selector ComboBox ListBox ListView MultiSelector TabControl StatusBar TreeView ButtonBase Button DropDownButton CheckBox RadioButton GridViewColumnHeader RepeatButton ToggleButton Panel Canvas DockPanel Grid TabPanel ToolBarOverflowPanel UniformGrid StackPanel VirtualizingPanel WrapPanel RangeBase ScrollBar ProgressBar Slider

Прочее полезное Decorator Primitives Popup Thumb Adorner Decorator ResizeGrip TickbBar Track TextBoxBase Decorator Adorner Decorator ButtonChrome ListboxChrome Border Viewbox InkPresenter ClassicBorderDecorator

Новые элементы управления Недавно вышли: DataGrid Calendar/DatePicker В CTP Ribbon*

Templates (Шаблоны) 11/27/2018 7:24 PM © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Шаблоны Шаблоны в WPF Look-less Controls (элементы без вида) Control Templates (шаблоны) TemplateBinding Демо: Шаблоны

Lookless Controls Элементы без вида WPF элементы абстрагированы от вида: Обеспечивают поведение Нет встроенной визуализации Внешний вид определяется отдельно от реализации В файле темы (theme file) Создается дизайнером Элементы обычно имеют стиль по умолчанию

Шаблоны (Control Templates) Определяют структуру элемента Визуальное дерево шаблона разворачивается для каждого экземпляра элемента

Шаблоны в WPF =

Шаблоны в WPF Переопределяют визуальное дерево Замена шаблона изменяет вид, но не поведенческую модель Каждый элемент управления в составе WPF имеет шаблон Шаблоны не наследуются через BasedOn свойство

TemplateBinding Связывает свойство элемента в шаблоне со свойством элемента, к которому шаблон применяется. Защищает свойства, установленные на дочерних элементах от переопределения в шаблоне Использует класс TemplateBindingExtension

11/27/2018 7:24 PM Шаблоны Демо © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

11/27/2018 7:24 PM Стили © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Стили Стили в WPF Расширение стилей Стили в XAML Применение стилей Демо: стили

Стили в WPF Коллекция значений свойств Группируются элементом <Style> типа System.Windows.Style Стили используются для определения шаблонов Стили именуются с помощью атрибута x:Key

Расширение стилей С помощью свойства BasedOn, указывающего на существующий стиль Все setters родительноского стиля наследуются потомком Стили могут использовать BasedOn вместе с x:Key

Расширение стилей

Применение стилей Стили могут быть применены: Name/Key (Имя или ключ) Type (Тип) Scope (Область видимости) Может использоваться комбинация этих методов Элемент использует стиль если он подходит по типу и области видимости или, используя атрибут Style

Применение стилей Name/Key Type Scope

11/27/2018 7:24 PM Стили Демо © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Произвольные элементы управления 11/27/2018 7:24 PM Произвольные элементы управления © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Произвольные элементы управления Произвольные элементы управления Способы создания UserControl Custom Controls

Возможности создания новых WPF три модели создания произвольных элементов управления : Наследовать от UserControl Наследовать от Control Наследовать от FrameworkElement

UserControls Создание UserControl позволяет осуществлять композицию существующих элементов Например контрол для поиска из Textbox и Button UserControl - ContentControl Чтобы создать UserControl Определить класс унаследованный от UserControl В XAML определить визуализацию UserControl из каких элементов он состоит

Custom Controls Создавайте custom controls для: Расширения существующего, например TextBox Получении элемента поддерживающего стилизацию через шаблоны (control template) Максимальное повторное использование Чтобы создать custom control: Определить класс, наслед. От Control Переопределить DefaultStyleKeyProperty Определить шаблон в /Themes/Generic.xaml ресурсном словаре

Пример Custom Control Derived from Control Override default style Control template in Generic.xaml

Произвольные элементы управления Наследование от FrameworkElement больше контроля над внешним видом Два метода: Direct Rendering: переопределение OnRender метода, DrawingContext операции для явного определения визуальных элементов Custom Element Composition: построение дерева на основе визуальных объектов

Произвольные элементы управления Произвольные элементы управления Visual Прямой рендеринг Композиция элементов UIElement Shape FrameworkElement Border Track Control

11/27/2018 7:24 PM © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION. © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.