КРУПНЕЙШАЯ ТЕХНИЧЕСКАЯ КОНФЕРЕНЦИЯ MICROSOFT В УКРАИНЕ Metro приложения: работа с данными Краковецкий Александр, MVP/RD/PhD. DevRain Solutions.

Slides:



Advertisements
Similar presentations
SILVERLIGHTSHOW.NET WEBINARS SERIES Michael Crump, July 3rd, 2012
Advertisements

Patterns & practices Symposium 2013 Tips for building a Windows Store app using XAML and C#: The Kona project Francis Cheung
Data Binding in GUI Application Development Patrick O’Brien.
Robert Green | Technical Evangelist Dmitry Lyalin | Product Marketing Manager.
Lessons learned from developing a Windows 8 Metro application in C# Frode Nilsen Nilsen Labs Ticki.
Tampa Bay Windows Developers User Group File…New…Metro Jan 18th 2012
An Introduction to the Model-View-ViewModel Pattern Srsly? Another MV* Pattern? Srsly? Another MV* Pattern?
Dinko Jakovljević Microsoft Student Partner | BambooLab
WinRT Apps
Всевоволод Головизнин, MVC – паттерн проектирование, в котором бизнес - логика, управляющая логика и интерфейс разделены на три отдельных компонента.
Microsoft Focus & Expertise We have a world-class team of Microsoft experts that can make any other platform integrate better with an existing enterprise.
Microsoft TechDayshttp:// Роман Здебский Эксперт по технологиям разработки ПО Microsoft
Ronnie Saurenmann Principal Architect Microsoft Switzerland
Real world Windows Phone development Igor
Building Silverlight Applications Using the MVVM pattern An Introduction by Peter Messenger Senior Developer – Qmastor
© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg.
Charles Petzold Controls and Data Binding.
‘Metro’ / Modern – ‘WinRT’ Also known as ‘Windows Store Apps’ --o-0-o-- Windows 8 comes as two parts Win32 and WinRT The Traditional Desktop is Win32 The.
Target: dependency property Source: any public property CLR and WPF properties Target: dependency property Source: any public property CLR and WPF properties.
An Introduction to Silverlight Matt Harrington Developer Evangelist, Microsoft October 20, 2011.
Windows Presentation Foundation. Agenda Introduction Developing Applications WPF and WF interoperability Custom Controls Styles and Templates Data Binding.
Windows Phone 8 Tips & Tricks for Developers Sascha Corti, Microsoft Switzerland Technical Evangelist | techpreacher.corti.com.
Adam Calderon – C# MVP Application Development Practice Lead Interknowlogy.
V 1.0 Programming III. Automatic notifications (…Changed, INofityPropertyChanged, ObservableCollection ) Data formatters Data conversions Resources.
LAYOUT CONTROLS. XAML Overview XAML : eXtensible Application Markup Language pronounced (ZAMEL) is a markup language used to design user interfaces XML-based.
The Windows Runtime (WinRT) is the shared runtime and API space used by store apps across the Windows platform (phone and client) 5 Common WinRT.
Future of VB and C# Lucian Wischik VB Language PM Microsoft.
Windows Phone MVVM and Unit Testing Step by Step Andy Wigley Windows Phone Development MVP, Mobile Software Consultant APPA Mundi Ltd WPH208.
Copyright ©2004 Virtusa Corporation | CONFIDENTIAL Windows Presentation Foundation Ruwan Wijesinghe.
Сергей Пугачёв Microsoft Silverlight 5, XAML и связывание данных.
Svetlin Nakov Telerik Corporation
V 1.0 Programming III. Converters Resources. V 1.0ÓE-NIK, 2014 Converters Data conversion: –Can be automatic! E.g.: SolidColorBrush  string, int  string.
HTTP ANDROID CLUB 2015.
개발자가 알아야할 Binding 강남 DataBinding 스타일 Windows 8 앱개발자라면 꼭 알아야할.
Canopy walk through Single-Page Apps (SPAs) Benjamin Howarth Freelancer, Code Gecko Umbraco UK Festival, Fri 30 th Oct 2015 CODE GECKO.
Windows 10 UWP MVVM In Depth
A Lap Around Windows Presentation Foundation (WPF) 4.5 Pete Brown | XAML and Gadget Guy Microsoft Corporation DEV335.
WebClient client; 10 // Constructor public MainPage() { InitializeComponent(); client = new WebClient(); client.DownloadStringCompleted.
04 |Sharing Code Between Windows 8 and Windows Phone 8 in Visual Studio Ben Riga
V 1.0 Programming III. Automatic notifications with data binding (…Changed, INofityPropertyChanged, ObservableCollection, DataTemplate) Data formatters.
New for dependency properties register for property changes.
V 1.0 Programming III. XAML Data Binding I.. V 1.0ÓE-NIK, 2014 XAML namespaces Namespaces define the allowed tags and attributes The one without the prefix.
Model View ViewModel Architecture. MVVM Architecture components.
Windows 8 apps and the MVVM pattern SILVERLIGHTSHOW.NET WEBINARS SERIES GILL CLEEREN, October 16 th
Programming with MVVM Miguel A. Castro Architect -
/DEV/TM #1 Building Cross-Platform Apps with Xamarin and MvvmCross Flavius-Radu DEMIAN.
Creating rich applications using Model View ViewModel David Ross
Data Binding, Binding Properties Doncho Minkov Telerik School Academy Technical Trainer
Building Metro style apps with XAML with.NET Tim Heuer Program Manager Microsoft Corporation DEV353.
Windows 8 App Development with XAML
In Windows 8 Store Applications
State of the Art in Mobile Development - AndRES Käver, 2016
Real world Windows Phone development
The Future of C# and Visual Basic
Ben Riga 02 | Basics of View Models Ben Riga
It’s a Knockout! MVVM Style Web Development
Build data-driven collection and list apps using XAML
Tips and tricks for developing Metro style apps using XAML
Integrating Security Roles into Microsoft Silverlight Applications
XAML Deep Dive for Windows & Windows Phone Apps Jump Start
Tech Ed North America /1/2018 4:27 PM Required Slide
Lists and List Items in Windows Runtime Apps
04 | UI Presentation & XAML
Page Navigation and Data Binding in Windows Runtime Apps
What’s new for Windows 8 Devs Part 2
DEV312 基于WPF的数据绑定.
Microsoft Office 4/3/2019 Deep Dive into native Universal App development with the Office 365 APIs Speaker name Title Microsoft Corporation © 2012 Microsoft.
ListView and GridView (2)
Bringing existing managed code into Metro style apps
An Introduction to the Model-View-ViewModel Pattern
Presentation transcript:

КРУПНЕЙШАЯ ТЕХНИЧЕСКАЯ КОНФЕРЕНЦИЯ MICROSOFT В УКРАИНЕ Metro приложения: работа с данными Краковецкий Александр, MVP/RD/PhD. DevRain Solutions

agenda What’s new and different for XAML developers in Windows 8 –Connecting to services to get data –Asynchronous patterns –Local data –How to format your data for Windows 8 controls You’ll leave with examples of how to Connect to web and local data Use data in Windows 8 Metro style apps

synchronous vs. asynchronous

// синхронная версия private void OnButtonClick() { TextBox.Text = new WebClient().DownloadString(" } private void OnButtonClick() { var dispatcher = Deployment.Current.Dispatcher; var client = new WebClient(); client.DownloadStringCompleted += (s, e) => { var result = e.Result; dispatcher.BeginInvoke(() => TextBox.Text = result); }; client.DownloadStringAsync(new Uri(" }

Представьте асинхронный мир без callbacks async. & await!

async превращает ваш метод в асинхронный await возвращает результат в основной поток по завершению выполнения задачи работает с любым объектом, у которого есть метод GetAwaiter()

async & await private void OnButtonClick() { FetchAll(); } public async void FetchAll() { var client = new WebClient (); string xml = await client.DownloadStringTaskAsync(uri); TextBlock.Text = xml; }

async & await var Feeds = new ObservableCollection (); public async Task GetFeedsAsync() { Task feed1 = GetFeedAsync(“ this.Feeds.Add(await feed1);... }

использование данных So you’ve downloaded data asynchronously, now what? –Your familiar LINQ skills still apply Binding to controls –ListBox –GridView Grouping in GridView controls –Using IGroupInfo

привязка данных (data binding) привязка данных – мост между UI и бизнес логикой может быть декларативной (XAML) или программной (в коде) модели привязки данных –One-Way –Two-Way –One-Time

value converters public class MyValueConvertor : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { return Math.Round((double) value); } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { return null; }

value converters // объявляем пространство имен xmlns:converter="clr-namespace:MyNamespace.MyValueConverter“ // объявляем в ресурсах конвертер // пример использования:

привязка данных к модели public class FeedData { public string Title { get; set; } public string Description { get; set; } public DateTime PubDate { get; set; } private var _Items = new List (); // ObservableCollection public List Items { get { return this._Items; } }

привязка данных к модели

DEMO: DATA BINDING

получение данных Сервис-ориентированные приложения –XML-over-HTTP –JSON-over-HTTP –ASMX Web Services –oData локальное хранилище

элементы управления Присутствуют: ListBox, ComboBox, FlipView, ListView (JumpViewer), GridView (ListView + Wrap панель внутри ItemsPanelTemplate), CarouselPanel Отсутствуют (возможно появятся в Toolkit): DataGrid, TabControl, TreeView, Menu, ContextMenu

элементы управления

ListView <ListView x:Name="ItemListView" ItemsSource="{Binding Items}" DisplayMemberPath="Title" Margin="60,0,0,10">

ListView <ListView x:Name="ItemListView" ItemsSource="{Binding Items}" Margin="60,0,0,10"> <TextBlock Text="{Binding Title}" FontSize="24" Margin="5,0,0,0" TextWrapping="Wrap" /> <TextBlock Text="{Binding Author}" FontSize="16" Margin="15,0,0,0"/> <TextBlock Text="{Binding PubDate}" FontSize="16" Margin="15,0,0,0"/>

templates Шаблоны позволяют повторно использовать один и тот же XAML код для разных ситуаций <TextBlock Text="{StaticResource AppName}" Style="{StaticResource PageHeaderTextStyle}"/>

MVVM Паттерн Model-View-ViewModel — это паттерн, применяющийся при проектировании архитектуры приложения. Первоначально был представлен сообществу Джоном Госсманом (John Gossman) в 2005 году как модификация паттерна Presentation Model. MVVM ориентирован на современные платформы разработки, такие как Windows Presentation Foundation, Silverlight, Windows Phone 7, Windows 8.Windows Presentation Foundation Silverlight

MVVM Паттерн MVVM делится на три части: Модель представляет собой данные, необходимые для работы приложения; Вид/Представление (View) - графический интерфейс; Модель вида (ViewModel) является с одной стороны абстракцией Вида, а с другой предоставляет обертку данных из Модели, которые подлежат связыванию.

MVVM public class Accomplishment : INotifyPropertyChanged { public string Name { get; set; } public string Type { get; set; }... public event PropertyChangedEventHandler PropertyChanged; private void RaisePropertyChanged(string propertyName) { if (this.PropertyChanged != null) { this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); }

MVVM public class ViewModel { public ObservableCollection Items { get; set; } public ViewModel() { // filling collection Acomplishments.Add(someObject); }

MVVM

MVVM public partial class MainPage : PhoneApplicationPage { // Constructor public MainPage() { InitializeComponent(); this.DataContext = new ViewModel(); }

ПОЛЕЗНЫЕ ССЫЛКИ И МАТЕРИАЛЫ Часть 6

Async homepage: What's New for Visual C#: What's New for Visual Basic: Consuming a JSON Service in Window 8 Metro Style Application 8-metro-style-application/ 8-metro-style-application/

ВОПРОСЫ?