Tips, Tricks, and Techniques for Building Killer Silverlight Apps Jeff Prosise

Slides:



Advertisements
Similar presentations
Building Localized Applications with Microsoft.NET Framework and Visual Studio.NET Achim Ruopp International Program Manager Microsoft Corp.
Advertisements

Build-Deploy-Test with Visual Studio Lab Management 2010 Pieter Gheysens Visual Studio ALM MVP – Sparkles User Group Lead VISUG (
Dinko Jakovljević Microsoft Student Partner | BambooLab
Open Source Rich Internet Applications with Silverlight & Moonlight Joseph Hill Product Manager, Novell.
HTML5 That’s what you need to know today Ingo Rammer, thinktecture
Designing and Developing a Windows Phone 7 Application in Silverlight End-to-End.
& Silverlight, Windows Phone 7, Windows Azure, jQuery, OData and RIA Services. Shaken, not stirred. Kevin
Switching on the cloud for Silverlight MSDN Live Meeting Gill Cleeren Microsoft Regional Director – Silverlight MVP Ordina Belgium.
Best Practices in Virtualizing RDS and VDI: THE Virtual Reality Check Ruben
| Basel Discovering Windows Azure Mobile Services and Media Services Ken Casada
MSDN How do I add Voice Commands to my application Find Install Voice Command Sets Search Search for {dictatedSearchTerms} Find Find.
Syncing Audio, Video and Animations in Silverlight Dan Wahlin.
Parallel Programming in.NET 4.0 Tasks and Threading Ingo Rammer, thinktecture
Virtual techdays INDIA │ Nov 2010 Developing Office Biz Application using WPF on Windows 7 Sarang Datye │ Sr. Consultant, Microsoft Sridhar Poduri.
Total Workstation Lockdown: Your Action Plan Jeremy Moskowitz, Group Policy MVP Chief Propeller-Head: GPanswers.com Founder: PolicyPak Software (policypak.com)
NuGet in Depth Making Open Source Suck Less at Microsoft Scott Hanselman
Adam Calderon – C# MVP Application Development Practice Lead Interknowlogy.
.NET Framework Danish Sami UG Lead.NetFoundry
Parallel Programming in.NET 4.0 Tasks and Threading Ingo Rammer, thinktecture
Claudio Lassala Software Developer EPS Software / CODE Magazine Session Code: DEV 201.
Poll Focus for this session Development methodology for rich media and in- stream advertising from a Silverlight 2 POV This is a “How To” session Looking.
LINQ, Take Two Realizing the LINQ to Everything Dream Bart J.F. De Smet blogs.bartdesmet.net/bart
Module 12 Attached Properties and Behaviors in WPF.
Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse.
Windows Phone MVVM and Unit Testing Step by Step Andy Wigley Windows Phone Development MVP, Mobile Software Consultant APPA Mundi Ltd WPH208.
Jeff Prosise Wintellect ( Session Code: WIA307.
Bill Campbell, UMB Microsoft's.NET C# and The Common Language Runtime.
Nikhil Kothari Software Architect Microsoft Corporation Session Code: WUX312.
2015 International TechNet Wiki Summit 2015 Nonki Takahashi Session - Small Basic and TechNet (Small Basic - Part 2)
Migration and Deployment of Office 2010 Steffen Krause Senior Technical Evangelist Microsoft Deutschland GmbH
Windows Azure for IT Pros Kurt CLAEYS (TSP Windows Azure, Microsoft EMEA)
3 private void equalsButton_Click( object sender, RoutedEventArgs e) { calculateResult(); }
Forthcoming SQL Azure Services: SQL Azure Data Sync & SQL Azure Reporting Mark Scurrell Lead Program Manager Microsoft.
04 |Sharing Code Between Windows 8 and Windows Phone 8 in Visual Studio Ben Riga
Friday, March 8 Creating real Custom Controls Kelvin van Geene 12:15.
CPSC 481 – Week #7 Sowmya Somanath
Switch on the LightSwitch Gill Cleeren Microsoft Regional Director / Silverlight MVP Ordina Belgium
Developing SaaS Applications with the Windows Azure Platform Vittorio Bertocci
Service Manager 2010 Real Life Example: The coffee workflow Mike Resseler & Alexandre Verkinderen Infront Consulting Group.
Building Robust, Maintainable Coded UI Tests with Visual Studio 2010 Brian Keller Sr. Technical Evangelist – Visual Studio ALM
Zlatan Dzinic Principal Consultant Microsoft Most Valuable Professional - SharePoint Business Connexion.
11 User Controls Beginning ASP.NET in C# and VB Chapter 8.
Troubleshooting Group Policy Jeremy Moskowitz, Group Policy MVP Chief Propeller-Head: GPanswers.com Founder: PolicyPak Software (policypak.com) Twitter:
Virtual techdays INDIA │ November 2010 Integrating Social Networks with ASP.NET Krishna Chaitanya T │ Future Web Research Lab, SETLabs, Infosys WE.
To OData or Not to OData Chris Eargle kodefuguru.com.
What’s new in Azure SDK 1.3 (and 1.4) Peter Himschoot Microsoft Regional Director Belux U2U Trainer/Architect
THE SOURCE OF 4 TH & MAYOR: CODE, HACKS, TRICKS Jeff Wilcox Senior Software Development Engineer Microsoft SESSION CODE: WPH308 (c) 2011 Microsoft. All.
Ben Riga 02 | Basics of View Models Ben Riga
Dive into Application Lifecycle Management with Visual Studio 2010
Build Windows 10 UWP MVVM Apps with Prism
Automating AD Administration with Windows PowerShell
Jim Fawcett CSE775 – Distributed Objects Spring 2011
Rock Hard: C++ Evolving
Implementing RESTful Services Using the Microsoft .NET Framework
Glenn Block MEF in the real world Glenn Block
Welcome! Please introduce yourself via the chat
Integrating Security Roles into Microsoft Silverlight Applications
SharePoint & jQuery: Better Together
Tech Ed North America /1/ :36 AM Required Slide
A walkthrough Corey Hynes | HynesITe, Inc
Unlocking the secrets of REST with WCF
WCF Web API, HTTP your way
Chris Eargle kodefuguru.com
TechEd /27/ :51 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered.
Silverlight 2 Mike Taulty Developer & Platform Group Microsoft Ltd
Opalis System Center Integration Packs Deep Dive
Bringing existing managed code into Metro style apps
Tech Ed North America /6/2019 2:07 PM Required Slide
Presentation transcript:

Tips, Tricks, and Techniques for Building Killer Silverlight Apps Jeff Prosise

Dynamic Assembly Loading AssemblyPart class represents an assembly that's part of a Silverlight application Assemblies typically packaged in XAPs AssemblyPart.Load loads assemblies into appdomains at run- time The key to dynamic assembly loading, but… Beware the JIT compiler! 2

Loading an Assembly 3 WebClient wc = new WebClient(); wc.OpenReadCompleted += OnOpenReadCompleted; wc.OpenReadAsync(new Uri("Widget.dll", UriKind.Relative));. private void OnOpenReadCompleted(object sender, OpenReadCompletedEventArgs e) { if (e.Error == null) { AssemblyPart part = new AssemblyPart(); part.Load(e.Result); }

DEMO Dynamic Assembly Loading

Dynamic XAP Loading XAPs can be loaded dynamically, too Download with WebClient Extract AppManifest.xaml from XAP and enumerate assemblies ("parts") Extract assemblies and load with AssemblyPart.Load Create class-library XAP by starting with Silverlight Application, not Silverlight Class Library

Enumerating Assemblies in a XAP 6 StreamResourceInfo sri = new StreamResourceInfo(xap, null); XmlReader reader = XmlReader.Create (Application.GetResourceStream(sri, new Uri("AppManifest.xaml", UriKind.Relative)).Stream); AssemblyPartCollection parts = new AssemblyPartCollection(); if (reader.Read()) { reader.ReadStartElement(); if (reader.ReadToNextSibling("Deployment.Parts")) { while (reader.ReadToFollowing("AssemblyPart")) { parts.Add(new AssemblyPart() { Source = reader.GetAttribute("Source") }); }

Loading Enumerated Assemblies 7 foreach (AssemblyPart part in parts) { Stream assembly = Application.GetResourceStream (sri, new Uri(part.Source, UriKind.Relative)).Stream; part.Load(assembly); }

DEMO Dynamic XAP Loading

Dynamic Localization Silverlight supports RESX localization Create resource DLLs from RESX files Resource DLLs == Satellite assemblies Data-bind XAML elements to auto-generated ResourceManager wrapper Two challenges How do you switch languages at run-time? How do you download satellite assemblies on demand rather than embed them in the XAP?

ObservableResources 10 public class ObservableResources : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; private static T _resources; public T LocalizationResources { get { return _resources; } } public ObservableResources(T resources) { _resources = resources; } public void UpdateBindings() { if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("LocalizationResources")); }

Enumerating Satellite Assemblies 11 StreamResourceInfo sri = new StreamResourceInfo(xap, null); XmlReader reader = XmlReader.Create (Application.GetResourceStream(sri, new Uri("AppManifest.xaml", UriKind.Relative)).Stream); AssemblyPartCollection parts = new AssemblyPartCollection(); if (reader.Read()) { reader.ReadStartElement(); if (reader.ReadToNextSibling("Deployment.Parts")) { while (reader.ReadToFollowing("AssemblyPart")) { parts.Add(new AssemblyPart() { Source = reader.GetAttribute("Source") }); }

Loading Satellite Assemblies 12 foreach (AssemblyPart part in parts) { if (part.Source.ToLower().Contains("resources.dll")) { Stream assembly = Application.GetResourceStream (sri, new Uri(part.Source, UriKind.Relative)).Stream; part.Load(assembly); }

DEMO Dynamic Localization

Dynamic Page Loading Navigation framework provides infrastructure for multi-page apps Default content loader loads pages from XAP PageResourceContentLoader No built-in support for remote XAPs Custom content loaders can load them from anywhere -INavigationContentLoader

Do-Nothing Content Loader 15 public class CustomContentLoader : INavigationContentLoader { private PageResourceContentLoader _loader = new PageResourceContentLoader(); public IAsyncResult BeginLoad(Uri targetUri, Uri currentUri, AsyncCallback userCallback, object asyncState) { return _loader.BeginLoad(targetUri, currentUri, userCallback, asyncState); } public bool CanLoad(Uri targetUri, Uri currentUri) { return _loader.CanLoad(AddFileNameExtension(targetUri), currentUri); } public void CancelLoad(IAsyncResult asyncResult) { _loader.CancelLoad(asyncResult); } public LoadResult EndLoad(IAsyncResult asyncResult) { return _loader.EndLoad(asyncResult); }

Registering a Content Loader 16

DEMO Dynamic Page Loading

Behaviors Combine triggers and actions into one package Useful when user-input events and actions taken in response to those events are tightly bound e.g., drag behavior requires coupling of MouseLeftButtonDown, MouseMove, and MouseLeftButtonUp events Derive from Behavior or Behavior Override OnAttached and OnDetaching AssociatedObject property references attachee 18

Implementing a Behavior 19 public class DisappearBehavior : Behavior { protected override void OnAttached() { base.OnAttached(); AssociatedObject.MouseLeftButtonDown += OnClick; } protected override void OnDetaching() { base.OnDetaching(); AssociatedObject.MouseLeftButtonDown -= OnClick; } private void OnClick(object sender, MouseButtonEventArgs e) { AssociatedObject.Visibility = Visibility.Collapsed; }

Applying a Behavior 20 xmlns:local="clr-namespace:namespace" xmlns:i="clr-namespace:System.Windows.Interactivity; assembly=System.Windows.Interactivity".

DEMO Behaviors

Stay up to date with MSDN Belux Register for our newsletters and stay up to date: Technical updates Event announcements and registration Top downloads Follow our blog Join us on Facebook LinkedIn: Download MSDN/TechNet Desktop Gadget

TechDays 2011 On-Demand Watch this session on-demand via Channel9 Download to your favorite MP3 or video player Get access to slides and recommended resources by the speakers

THANK YOU