Silverlight User Group Meetup – Jan 2012


  • Title: How to develop and deploy Silverlight using WCF RIA services on Windows Azure
  • Synopsis: Windows Azure is a cloud based service which supports Silverlight WCF RIA services. This topic discuss about how to develop a simple application using WCF RIA service. Later the application will be deployed to the Windows Azure for accessing it over internet. We also discuss on basic featured of Azure services.
  • Speaker: Senthamil Selvan
  • Date and Time: 12th January, 2012 ( 7:30 PM to 9:30 PM )
  • Location: Microsoft Singapore, Conf Room SINOMB 22CF-12 (60) VTC
  • Admission: Free

Silverlight 5: MVVM got more fun with Implicit Data Templates

A few years back, Julian Dominguez from Microsoft pattern and practice team proposed a solution that uses Implicit Data Teamplate for WPF MVVM application development. You can read the details in his blog post “Presentation Model with DataTemplates in CompositeWPF (Prism) Sample“.  I was working in Xuenn developing WPF applications for sport betting platform at that time and we introduced Julian’s approach to team. We found both advantages and disadvantages of using this approach (I will share with you all the details soon.) but using “Implicit data template” did help a lot for some scenarios.  I’ve been requesting this feature to the team again and again for last a couple of years and I’m really glad that Silverlight team added it in Silverlight 5.

What is Implicit Data Template?

Implicit data template is something similar to “Implicit style” that was introduced in Silverlight 4. When you define a data template in <*.Resources> or resource dictionary, you used to define the key over there and reference it from the place where you want to use that data template. With implicit data template, you don’t need to define any key for your data template. There is a new property called “DataType” where you can define the type of data (Model) in data template that you want to use.

The code will be something like that below ~


<DataTemplate DataType="local:MyAwesomeModel">
....
</DataTemplate>

In this example, our model is called “MyAwesomeModel” and we set it to the “DataType” property of data template. Of course, you can create any template you want inside that data template as usual. After that, you can directly bind this model with UI (e.g. ContentControl or ItemControl ). The template that you created will be displayed on the UI when you run the project. How simple it is?

In order to show this feature, I created one demo with metro design in my mind (even thought I’m not professional designer. )

Download :  ImplicitDataTemplatesDemo from github

What I did in this sample is pretty simple. I created an interface called “IPerson” which has three properties such as Name, Description, ProfilePhoto. And, I created three models (MichaelSync, ElenaSync and ShwesinSync) that implement “IPerson” interface. Note that I didn’t implement INotifyPropertyChanged or the setter in any of the classes but you may want to implement them in real project.


public interface IPerson {
 string Name { get; }
 string Description { get; }
 BitmapImage ProfilePhoto { get; }
}

In MainPage, I set the DataContext in order to make the bindng work. Yap! I have to set it before initializing the components. I added new property called “People” and filled it up with the instances of models.


public partial class MainPage : UserControl
{
 public MainPage()
 {
 this.DataContext = this;
 // Required to initialize variables
 InitializeComponent();

People = new List{
new MichaelSync(),
new ElenaSync(),
new ShwesinSync(),
 };
 }

public IList People { get; set; }
}

There is only one ItemControl that bind to “People” property.

<Grid Width="640" HorizontalAlignment="Left">
 <ItemsControl ItemsSource="{Binding People}" Margin="41,84,41,0"/>
</Grid>

I created three data templates with different data type as below.

When you run it, you will see beautiful metro style application with my family photos. I’m just trying to show you one scenario that you can use but if you really want to use MVVM with implicit data template, I would recommend you to read Julian’s post.

Pros and Cons of using Implicit DataTemplate in MVVM

I would say that Julian’s approach is kinda extreme MVVM approach because it limited you from having any code behind code in View but it does help you more code cleaner (Oh no! I’m not counting code. )  and force developers to use MVVM in proper way (like creating blend bahivors or attached properties or etc). Another good thing is that you can directly bind your model with UI without explicitly calling the views.

Good

  • Cleaner and encourage the proper way of doing things
  • Easier binding

Bad

  • sometimes, it makes developers’ life damn difficult.

That’s all from my side.

Happy Silverlighting!

Silverlight 5 for Christmas

The release of Silverlight 5 is announced on Silverlight team blog a few days back. You can go and download it from this link. I’m very glad that Silverlight team managed to add some features that we requested. Thanks Silverlight team!

One interesting thing that I noticed is that SL team put a link to Microsoft Silverlight Support Lifecycle Policy in the announcement post. I’m happy to know that they are still going to ship updates for Silverlight 5 in future and they promised that SL5 will work on those browsers until 10/12/2021.

Here is the list of features shipped with Silverlight 5. It’s just a copy and paste from “What’s new in Silverlight 5” document.

Improved media support

  • Low Latency Audio Playback: Use the SoundEffect API to trigger low-latency sound
  • Variable Speed Playback: allows video to be played at different speeds and supports fast-forward and rewind. At up to twice the speed, audio pitch correction allows users to watch videos while preserving a normal audio pitch.
  • H/W Decode of H.264 media: Significant performance improvements with H.264 media decoding of unprotected content
  • DRM Key Rotation/LiveTV Playback: Long-running live TV playback protected through the use of rotating licenses
  • Application-Restricted Media: Prevents playback of protected content in unauthorized applications

Improved Text support

  • Text Tracking & Leading: Exercise fine-grained control over the spacing between characters and lines in your text
  • Linked Text Containers: Create linked RichTextBlocks that allow text to flow seamlessly from one to the next
  • OpenType and Pixel Snapped Text : Improved text clarity
  • Postscript vector printing: reduces the size of print jobs and improves rendering quality of text
  • Performance improvements for Block Layout Engine.

Building next-generation business applications

  • PivotViewer — now included in SDK. Adds support for dynamic client-based collections, XAML-based visuals, and customizability.
  • ClickCount: Add support for multi-click to your application
  • Listbox/ComboBox type-ahead text searching: Listboxes and ComboBoxes can now scroll based on text input
  • Ancestor RelativeSource Binding: Bind to a property on a parent control
  • Implicit DataTemplates: Allow DataTemplates to be defined implicitly
  • DataContextChanged event
  • Added PropertyChanged to the UpdateSourceTrigger enum
  • Save File and Open File Dialog: Specify a default filename when you launch your SaveFileDialog and specify a default directory when you launch your OpenFileDialog
  • Databinding Debugging: Set a breakpoint directly in XAML, examine locals, and debug your bindings
  • Custom Markup Extensions: Execute custom code at XAML parse time
  • Binding on Style Setters: You can now specify a binding within a style

Silverlight 5 performance improvements

  • Parser Performance Improvements: Improved XAML parse times for UserControls & ResourceDictionaries
  • Network Latency Improvements: Significant performance improvement in ClientHttpWebRequest scenarios
  • H/W accelerated rendering in IE9 windowless mode: Silverlight now uses the new SurfacePresenter APIs for H/W accelerated rendering in IE9 windowless mode
  • Multicore JIT: Shortens the start-up time for Silverlight apps
  • 64-bit browser support

Graphics improvements

  • Improved Graphics stack: The graphics stack has been re-architected to add features such as Independent Animations
  • 3D: Use the XNA API on the Windows platform to gain low-level access to the GPU and draw vertex shaders and low-level 3D primitives. Includes Render targets, XNA built-in effects, surface composition settings for depth/stencil buffers and multi-sample anti-aliasing

Silverlight 5 extends features of the “Trusted Application” model

Silverlight 5 extends features of the ‘Trusted Application’ model to the browser for the first time. These features, when enabled via a group policy registry key and an application certificate, mean users won’t need to leave the browser to perform complex tasks:

  • Multiple window support: Launch multiple top-level windows inside a SL OOB application
  • Full-Trust in-browser: Using Group Policy, deploy signed in-browser applications that harness the full power of full-trust functionality
  • In-browser HTML support: Host your WebOC within an in-browser SL application
  • Unrestricted File System Access: Read from and write to any directory on your system, from a full-trust application
  • P/Invoke support : Allows existing native code to be run directly from Silverlight

Tools improvements

  • Visual Studio Team Test support.

X-Calibre Hackathon – Win Nokia Lumia devices, and $7K USD worth of cash prizes.

My friend “Chris Ismal” from Nokia posted about the event that he and his team are organizing in our Singapore Silverlight Facebook page. This event is called ” X-Calibre Hackathon”. It’s a full day event that developers come and build the application for Windows Phone by using latest Windows Phone 7.5 (mango) features.

You can read the details on their official website. I copied and pasted some informations for you here as well.

Winners will ride away with a trophy unlike any other, and Nokia Lumia devices to the 1st prize winning team, and…

  • 1st prize -$4,000 USD
  • 2nd prize – $2,000 USD
  • 3rd prize – $1,000 USD

The winning apps will also be featured in Nokia’s App Highlights and Amazing Everyday Marketing Campaign!

What is X-Calibre Hackathon?

X-Calibre Hackathon is a one-day Windows Phone application building contest (9am – 6pm) happening on November 19, 2011 where developers compete to create the best WP app using Mango features such as  Metro UI, Live Tiles, Fast App Switching etc.

What is the judging criteria? 

Judging will be done by representatives from Nokia, Microsoft, and the WP Champs.  There will be no criteria weightage.  Judging will simply be based on “the best Windows Phone app that uses Mango features such as Metro UI, Live Tiles, Fast App Switching, and others!”

What are the contest details?

  1. The chosen 60 participants will be divided into 4 groups each stationed at different locations.  Groups will compose of teams with maximum 3 members each team.  In total there will be 20 teams.
  2. Two Windows Phone Champs will be managing and providing technical support to each of the groups.  In total there will be 8 Champs.
  3. The contest will commence at 9:00 am simultaneously throughout the locations.  The Champs will be on-location until 6pm.  Venue is only available until 6:00 pm.  Contest (submission) ends 11:59 pm on the same day.
  4. Bring your own laptop, wifi, and food!5. Contest winners will be announced at the Awarding event in Nokia Singapore (date to be confirmed)

Blend 4 + VS 2011 (Preview) = Problem?

Problem: 

Microsoft Expression Blend 4 crash on startup after installing Visual Studio 2011 Developer Preview on my machine..

Solution: 

I found this bug report in MS Connect.  Christopher Cole from Microsoft Expression responded that report with the solution below.

There is a compatibility problem with .Net 4.5 installed as part of the Developer Preview and Blend 4. This issue was fixed, but too late to make the preview build.

The workaround is to run:

%windir%\Microsoft.NET\Framework\v4.0.30319\ngen uninstall “%ProgramFiles(x86)%\Microsoft Expression\Blend 4\Microsoft.Expression.Framework.dll”
%windir%\Microsoft.NET\Framework\v4.0.30319\ngen uninstall “%ProgramFiles(x86)%\Microsoft Expression\Blend 4\Microsoft.Expression.Blend.dll”
%windir%\Microsoft.NET\Framework\v4.0.30319\ngen uninstall “%ProgramFiles(x86)%\Microsoft Expression\Blend 4\Microsoft.Expression.Project.dll”

If “%ProgramFiles(x86)%\Microsoft Expression\Blend 4\Microsoft.Expression.WindowsPhone.dll” is present (for scenarios like Blend V4 SP1 or future releases), please also run:
%windir%\Microsoft.NET\Framework\v4.0.30319\ngen uninstall “%ProgramFiles(x86)%\Microsoft Expression\Blend 4\Microsoft.Expression.WindowsPhone.dll”

I just tried it on my machine and it works for me so I’m sharing it with my readers here..

Edit: 

Error: Unrecognized option Files

You have integrated Git with Command Prompt, you will get this error when you run “ngen”. If you happen to have the older preview version of git, you will get the error below when you try to uninstall it. I had to delete the git folder manually.

—————————
Error
—————————
Runtime Error (at 18:1292):

Could not call proc.
—————————
OK
—————————

 

 

Singapore Silverlight User Group – June 2011 Meetup

Guys! It has been a while since we had our group meetup in Nov. So I think it’s time for us to meet up again..:)  As you all know, Microsoft released Silverlight 5 Beta and demonstrated about Windows Phone 7 “Mango”  update recently.. I’m sure that you guys might have a lot of questions about this update.. That’s why we invited Chris from Microsoft to give a talk about WP7 mango update in our group meetup. Please feel free to come and you can bring your friends as well. See you all!!

  • Topic : Windows Phone 7 “Mango” Update
  • Speaker : Chris Ismael (Microsoft)
  • Date: 28th June, 2010
  • Time: 7 PM – 10 PM
  • Location: Microsoft (22CF-12)