1 / 36

A Lap Around Windows Presentation Foundation ( WPF) 4.5

DEV335. A Lap Around Windows Presentation Foundation ( WPF) 4.5. Pete Brown | pete.brown@microsoft.com XAML and Gadget Guy Microsoft Corporation. XAML UI is Everywhere. Not identical, as you know, but closer than any two other technologies . Share talent / skill Share patterns

dirk
Télécharger la présentation

A Lap Around Windows Presentation Foundation ( WPF) 4.5

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. DEV335 A Lap Around Windows Presentation Foundation (WPF) 4.5 Pete Brown | pete.brown@microsoft.com XAML and Gadget Guy Microsoft Corporation

  2. XAML UI is Everywhere Not identical, as you know, but closer than any two other technologies. • Share talent / skill • Share patterns • Share code • Share the love

  3. 4.0 WPF 4.0 Looking back at the current release • Very strong release • Huge performance improvements • Huge text rendering improvements • Visual Studio Shell first rewritten in WPF 4.0 • Controls • DataGrid, Calendar, Datepicker • Improvements from Silverlight land • Visual State Manager • Easing Functions

  4. 4.5 WPF and .NET 4.5 Releases Go-Live License Included

  5. 4.5 Supported Platforms • Desktop WPF 4.5 development • Requires Visual Studio 2012 • Windows 7 and Windows 8 (x86 and x64) • Windows Server 2008 R2 (x64) • Windows Server 2012 (x64) • Runtime support • Windows 7 and Windows 8 (x86 and x64) • Windows Server 2008 R2 (x64) • Windows Server 2012 (x64)

  6. 4.5 Drivers for Creating WPF 4.5 • Customer feature feedback • UserVoice • Large ISV customers • Targeted updates and features • Stability, smoothing, performance • Windows 8 Metro also uses .NET 4.5 • Internal customers • Visual Studio 11 shell written in WPF • Expression Blend, Powershell, more

  7. 4.5

  8. 4.5 Primary WPF 4.5 Features • New async and await and Task<T> support • Built-in Ribbon control and Ribbon window • Data binding update delay (for sliders etc.) • Static property binding/change notification • Event weak references • Binding expression information • INotifyDataErrorInfo • ICustomTypeProvider • Accessing collections on non-UI threads • Live shaping of collections • Bug fixes, performance improvements, more • Full list: http://bit.ly/wpf45dp

  9. 4.5 Feature: Ribbon • Mature control, delivered as part of the product • No longer a separate download • Ribbon is important on Windows 7 and Windows 8 desktop • System.Windows.Controls.Ribbon • Ribbon, RibbonWindow, RibbonTab, RibbonButton etc. enhanced

  10. Ribbon

  11. 4.5 Feature: Async and Await Support • Greatly simplify asynchronous code • Especially suitable for networking operations • Relies on • New C# language feature • Task<T> and the Task Parallel Library • Helps make your code more easily portable to Windows 8 Metro style apps • Compatible with WPF 4.5, Metro C# and WinRT, Silverlight 5 on VS2012 new

  12. async and await

  13. 4.5 Feature: Binding Delay • Configurable delay until target is updated • Restarts with each property change • Reduce load on binding system and UI • Updates and related events can be expensive • Helps control the quantity of events and binding updates • Apply it to the correct control • Must be applied to the source control when element binding new

  14. Binding Delay • <Slider x:Name="ValueSlider" Minimum="0" Maximum="100" • Margin="20" Height="25" • Value="{Binding ElementName=ValueText, • Delay=500, Path=Text, Mode=TwoWay}" /> • <TextBoxx:Name="ValueText"Text="50" • Width="100" Height="50" • FontSize="20" HorizontalAlignment="Center" />

  15. Binding Delay

  16. 4.5 Feature: BindingExpression APIs • New APIs for accessing binding expression information • ResolvedSource (source object) • ResolvedSourcePropertyName (property) • Target (target object) • TargetProperty (target property) • more enhanced

  17. 4.5 Binding to Static Properties • Another customer request • However, not necessarily the best pattern, but useful at times • Consider singletons or IoC / injection as alternatives • Lifetime difficult to control • When you need it, you need it new

  18. Static Binding • Property="{Binding Path=(namespace:class.property)}" • public static event • EventHandler<PropertyChangedEventArgs> • StaticPropertyChanged;

  19. Binding to Static Properties

  20. 4.5 Feature: Weak Events • Built-in Support for the Weak Event Pattern • Use when listener doesn’t know when to unhook event handler • Helps avoid memory leaks • Generic WeakEventManager • Uses reflection • Flexible, but not as efficient • Derive your own for more runtime efficiency enhanced

  21. Event Weak References

  22. 4.5 Feature: Virtualization Improvements • Virtualizating panels like VirtualizingStackPanel can now specify scroll units • Pixel : Partial items are displayed • Item : Only whole items are displayed • Set cache size • CacheLengthUnit : Page, Item, Pixel • CacheLength: Separate values for above and below • Grouping support • IsVirtualizingWhenGrouping enhanced

  23. 4.5 Feature: Cross-Thread AccessCollection synchronization • Before • Collections could not be modified except on the thread which created them • Lots of ugly dispatcher calls • Now • Get a lock for the collection • Enable synchronization • Update it from any thread new

  24. Collection Synchronization • public ObservableCollection<Stock> Stocks • { get; private set; } • private object _stocksLock = new object(); • public MainViewModel() • { • Stocks = new ObservableCollection<Stock>(); • BindingOperations.EnableCollectionSynchronization • (Stocks, _stocksLock); • }

  25. Virtualization and Cross-Thread Access

  26. 4.5 Feature: ICustomTypeProvider • A way to create class properties on the fly • Useful for data-driven systems • You control definition and storage of values at runtime • Silverlight 5 compatible • Similar to ICustomTypeDescriptor • But without recreating all the reflection calls • See Silverlight 5 examples new

  27. 4.5 Feature: INotifyDataErrorInfo • Initially added to Silverlight 4 and WCF RIA Services 1.0 • Compatible version in WPF 4.5 • Supports asynchronous validation • Typically a server-based validation call • Lots of Silverlight example code which applies here new

  28. 4.5 Feature: Live Shaping • Sorted collection changes intelligently applied to DataGrid • Including property changes for elements in the collection • Requires a CollectionView • Set sort/filter/group descriptions • Tell it which fields to watch • Tell it you want to live sort/filter/group • Keep performance in mind new

  29. Shaping

  30. Related Content • DEV353 Building Metro style Apps with XAML (Tim Heuer) • DEV216 MVVM in XAML: Simple and Easy (Paul Sheriff) • DEV369 Creating LOB Metro style Apps in XAML (Jeffrey Ferman) blog: http://10rem.net | twitter: @pete_brown | pete.brown@microsoft.com Find me right after this session at bookstore for SL5 in Action book signing

  31. DEV Track Resources • Visual Studio Home Page :: http://www.microsoft.com/visualstudio/en-us • Somasegar’s Blog :: http://blogs.msdn.com/b/somasegar/ • Jason Zander’s Blog :: http://blogs.msdn.com/b/jasonz/ • Facebook :: http://www.facebook.com/visualstudio • Twitter :: http://twitter.com/#!/visualstudio

  32. Resources Learning TechNet • Connect. Share. Discuss. • Microsoft Certification & Training Resources http://northamerica.msteched.com www.microsoft.com/learning • Resources for IT Professionals • Resources for Developers • http://microsoft.com/technet http://microsoft.com/msdn

  33. Required Slide Complete an evaluation on CommNet and enter to win!

  34. MS Tag Scan the Tag to evaluate this session now on myTechEd Mobile

  35. © 2012 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.

More Related