Minor update to the Silverlight MVVM frameworks explorer

Silverlight, WPF No Comments »

Thanks to the readers who gave me feedback on my Silverlight MVVM frameworks explorer I updated the application this morning in order to fix some problems.

Here is the change set:

  • fix incorrect URLs
  • fix incorrect “Silverlight Support” options. As Laurent Bugnion said in the comments, his MVVM Light framework was the only one supporting Silverlight which was strange…
  • links now open in a new window

Click on the following image to launch the Silverlight application.

About adding new frameworks, I’m not sure to add those which targets a much larger domain than MVVM itself. CompositeApplication guidance for example is a lot more than MVVM…

WPF internals part 2 : how the WPF controls are organized ?

.Net, Silverlight, WPF No Comments »

A couple of weeks ago, I started a series of articles about WPF internals organization. In the first article I did a tour of the core WPF classes. In this second part, I’m reviewing the organization of the various controls that exist in the framework.

Because the image of the diagram is pretty big, I decided to use Silverlight DeepZoom and the result is just below this text :-) You can download the full image resolution here. Please use the full screen button in the upper right corner of the viewer for the best browsing experience.

    Here are general remarks that might help you get information from those diagrams.

    The top level Control class:

    • Defines general UI properties such as Background, Foreground, BorderBrush and BorderThickness
    • Defines a set of properties to control font rendering: FontFamily, FontSize, FontStyle…
    • Has a DoubleClick event (other mouse events such as MouseUp/MouseDown comes from the UIElement class)

    Below the Control class, we have (this list is not complete):

    Below the ContentControl class we can find many existing WPF controls:

    General other remarks:

    • It’s funny to see that both Window and UserControl inherits from ContentControl. Before doing the diagram I though that Window came from somewhere else :-)
    • Having those diagrams in mind (or on a screen !) is very useful when you need to create your own custom control
    • We can see the differences between creating a custom control (inherit from Control or derived class) and a UserControl (inherit from UserControl)
    • .Net4 will introduce new controls (not in this diagram) in the WPF framework such: DataGrid, Calendar, TimePicker

    kick it on DotNetKicks.com

    Review of 2009 blog posts

    General No Comments »

    In the past year, I’ve posted more than 30 articles on my blog. Here is a summary of those posts (link in bold are those which got the most traffic during the year). Obviously, MVVM was a very hot topic during 2009 :-)

    January

    February

    March

    April

    May

    July

    August

    September

    October

    November

    Windows Azure challenge

    Events No Comments »

    A couple of weeks ago, the French developpez.com website launch a challenge in collaboration with Microsoft to help developers discover the Windows Azure platform.The goal was to succeed 5 different steps in order to win the challenge and get two prizes. The first one was a wifi teeshirt and the second one the new Microsoft Arc Mouse.

    It was my first real experience with the Azure platform and I was very happy to be able to manipulate the platform through various real-world example. The steps were the following:

    1. Deploy an existing application on Azure
    2. Modify an existing application and then deploy it on Azure
    3. Deploy an existing application using Blob storage
    4. Fix a Winforms application using the Azure API to backup files and folder
    5. Answers several questions about the Azure platform

    The steps were both educational (each time we discovered a new feature) and challenging (we must make it work !). I would like to thank very much the organizers of this event: Jérôme Lamber, Louis-Guillaume Morand, Phillippe Vialatte, Pierre Couzy and Thomas Lucchini.

    Hopefully, we’ll see more challenges in the future on the developpez.com website.

    2010 roadmap

    General No Comments »

    I wish a happy new year to all my readers across the web. I thank you for all the feedback I got during the past year and I hope we will be able to exchange more in 2010. In this post, I’m sharing with you my roadmap for interesting events and dates in 2010:

    • January 7-10th: CES (Consumers Electronic Show) in Las Vegas
    • February 8th – 10th: Microsoft TechDays in Paris. I’ll be there  for the event and I’m hoping to be recruited by Microsoft for the ATE (Ask The Expert) stand where I’d like to share my WPF experience with other developers
    • March: release of Visual Studio 2010 and .Net 4.0 RC
    • March 15-17th: MIX10 in Las Vegas. We can expect more announcements about Silverlight4 and hopefully some information about the future of Silverlight on mobile and demos of Windows Mobile 7 as well
    • April: release of Visual Studio 2010 and .Net 4.0 final
    • Autumn : release of Windows Mobile 7

    I think 2010 is going to be an exciting year with VS2010, .Net4, Silverlight4 and hopefully a mobile version of Silverlight too. Stay tuned :-)

    Discover and compare existing MVVM frameworks !

    .Net, Silverlight, WPF 10 Comments »

    A couple of weeks ago, I wrote a blog post where I compared the existing MVVM frameworks. This post became a bit famous in the WPF/Silverlight blog world and I received a lot of feedback to update the list, fix information, etc. I also got a request from Erik suggesting me to put all the datas in a matrix.

    Today I’m proud to announce the MVVM frameworks Silverlight application (click the image to open the Silverlight3 page).

    silverlight-mvvm-app

    A couple of observation:

    • please contact me via this blog or twitter if you find incorrect information
    • I’m not judging anybody’s work by giving rating, it’s just my personal feeling to have an easiest way to sort the data

    Hope you’ll like it :-)

    PDC09 : How VS2010 was built with WPF ?

    .Net, Events, Tools, Visual Stutio, WPF No Comments »

    PDC09

    In my last blog post, I did a review of a PDC09 Session “Advanced performance tuning with WPF”. Today, I’m doing a review for another very interesting session “How VS2010 was built with WPF ?”. The video is available here.

    vs2008tovs2010

    Why did Microsoft choose WPF for VS2010 ?

    • Technological: prove the capabilities of WPF4
    • Architectural
      • Separated presentation
      • Support for long range road map (+10 years)
    • Key VS2010 features need it: Editor, Architecture Editor, Parallel tools debugging
    • Take an opportunity to give feedback for WPF4: when VS2010 development started, .Net 3.5 SP1 was just shipped and it was the right time to give feedback for the new features and fixes for WPF4.

    It is worth noting that VS2010 is a project that is being watched carefully inside Microsoft. We can expect that more Microsoft applications will move to WPF in the next coming years.

    What WPF features are used ?

    • Declarative UI using XAML
    • Databinding
    • Styles and templates
    • Application Resources
    • Interop Win32 (because they did not have the time to rewrite everything using WPF or because features doest not need to use WPF for example de WinForms designer…)
    • Integration with the message loop (to deal with particular focus issues)
    • New text stack (part of WPF4) based on DirectWrite

    Staged approach

    • Define data models: a huge diagramming and architectural exercice
    • Replace the main window with WPF (only the window not its content !) to start the mix approach (managed/unmanaged, WPF/Hwnds)
    • Write new managed components: Window manager, command bar presentation
    • Scout with other VS teams
    • Test, Test, Test…

    What were the challenges ?

    • Mixed mode application: native and managed code; WPF and HWNDs (Win32 or WinForms)
    • Keep existing extensions working and allow new extensions to take advantage of WPF
    • Don’t “stop the train” other teams were working at the same time on the product to add new functionalities
    • Text clarity
    • Performance
    • Focus management

    You can watch the session here if you want more detail and demos of what I mention in this post.

    PDC09: Advanced WPF Application Performance Tuning

    Events, WPF 2 Comments »

    PDC09

    In this post, I’m doing a review of the Advanced WPF Application Performance Tuning session of PDC09.

    1. Introduction

    WPF = Designer + Developer:

    • Designer: Resources constraints, Drawing effects, Excessive use of images, “Rich” template
    • Developer: Loaded modules, Startup time (cold and warm time), Memory leaks (it’s not because we have a GC that leak doesn’t exist), Large element count

    Performance general truth:

    • Measure, measure, measure (identify key scenarios and set clear goals)
    • Low hanging fruit: identify parts that need optimized (to avoid spending time on optimizations that will not be perceived by the user)
    • Perceived performance is the most important thing: make it feel fast
    • Trade-offs: CPU vs memory…

    After this short intro, the speaker introduce FishBowl a sample WPF application that brings Facebook on our desktop. This app will be used as a reference in the rest of the session to demonstration optimization techniques.

    fishbowl

    2. Memory usage

    The demonstration starts using Process Explorer to have a look at the memory usage of the app which is about 150MB. This seems quite high for such an application. By using VMMAP, the speaker finds out that the native heap is 100MB whereas the managed heap is only 50MB. This seems strange for a pure WPF application.

    There is always native heap (render thread…), but when it’s particularly large, it’s generally related to images used in the application.

    By browsing the source code of FishBowl, the speaker shows that the startup animation is not XAML based but uses more than 100 PNG images holding more than 30MB of memory (that will be in the native heap).

    Using .Net memory profiler, the speaker finds out that the bitmap images used in the startup animation are not released when the animation is over causing a memory leak.

    3. Cold Start

    Cold start is all about disk I/O, we must minimize the amount of data that must be read from disk. The speaker shows that System.Window.Forms and System.Drawing assemblies are loaded during startup whereas it should not be the case for a pure WPF app (and about 300ms could be saved).

    Then using the “Show hierarchical” feature of the .Net memory profiler, he finds out that System.Drawing only has 1 instanciated type (the Rectangle class !). By changing the code to remove those dependencies he prevents those 2 DLLs from loading in the startup process and improve the startup time !

    Although by changing this code:

    ?View Code CSHARP
    1
    2
    3
    4
    5
    6
    
    if(Properties.Settings.Default.EnableLoggin)
    {
      // LogEntry is defined in the Entreprise Logging Library DLL
      // and use this class will cause the assembly to be loaded
      var entry = new LogEntry();
    }

    Into this one:

    ?View Code CSHARP
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    
    if(Properties.Settings.Default.EnableLoggin)
    {
      // the previous code has been moved to a dedicated method
      this.LogMessage();
    }
     
    [MethodImpl(MethodImplOptions.NoInlining]
    private void LogMessage()
    {
      // code that uses LogEntry and needs to load the Loggin assembly
    }

    We can prevent the DLL from being loaded when the loggin option is not enabled ! Notice the MethodImpl attribute that prevents the compiler from inlining the method (which would take us back to the original code…)

    4. Warm start

    During warm start we’re not expecting to see as much I/O as during cold start. The first tool that should be used to analyze warm start is a CPU profiler.

    In the FishBowl app, the main ListBox does not have virtualization turned on because each item has a variable height which cause a hang in the startup process. In order to improve the experience of the user, the app has been updated to load the elements in a background thread.

    The real performance is not changed here, but the perceived performance for the user is much better because he has a visual feedback instantly !

    5. RunTime

    Using WPFPerf, it’s possible to find out what the CPU usage is (between animation, layout, rendering…). The perforator tool gives various graphs such as Frame Rate, Software and Hardware IRTs (Intermediate Render Target).

    Currently if a Rectangle has DrapShadowEffect with an Opacity of 0, it is still computed by the rendering thread (it could be an optimization that WPF does internally but it’s not yet the case) which can cause performance issue when the parent item is animated.

    A possible optimization is to split the Rectangle into 2 Rectangles:

    • the first one with the effect and an opacity of 0 (on the Rectangle itself not on the effect like previously)
    • the second one without any effect and an opacity of 1 (visible), a storyboard is set on this rectangle to make the first element visible by animating its opacity

    In this case, because the first Rectangle is hidden (Opacity = 0), the cost needed to animate this rectangle is much better.

    Aditionnal recommendations:

    • don’t block on the UI thread
    • use virtualization, if you can’t use it, improve the perceived performance by loading the items in a background thread
    • data virtualization
    • freeze your freezable !

    6. Summary

    • Memory: images size, memory leaks, elements count
    • Cold start: disk I/O, module loads, NGen
    • Warm start: avoid blocking, delay work, perceived perf
    • RunTime: beware of IRTs, eventing

    7. Tools

    • Process Explorer in order to know how much memory has been allocated
    • VMMap where the memory is going ? (native head, managed heap…)
    • .NET memory profiler the profiler that is being used by the WPF team internally at Microsoft
    • ETW: event tracing
    • WPFPerf: WPF performance analyzer

    PDC09: some WPF sessions are available !

    Events, WPF No Comments »

    PDC09

    Earlier today, I mentioned that PDC09 videos will be available soon.

    The first WPF videos are now available ! This article will be updated once new videos become available:

    • How Microsoft Visual Studio 2010 Was Built with Windows Presentation Foundation 4 [VIDEO HERE]
    • Advanced Windows Presentation Foundation Application Performance Tuning and Analysis [VIDEO HERE]
    • Mastering WPF Graphics and Beyond [VIDEO HERE]
    • Windows Presentation Foundation 4 Plumbing and Internals [VIDEO HERE]
    • XAML Futures in Microsoft .NET Framework, Microsoft Silverlight and Tools [VIDEO HERE]

    PDC09: some announcements

    Events No Comments »

    PDC09

    Some announcements have been made yesterday during PDC09:

    - Silverlight4 Beta is available to download. The list of new features is available here, here are the most important:

    • Mic and webcam support
    • Printing support
    • Right click support
    • Binding improvements (we can now make binding between DependencyObjects, for example we can bind a TextBox and Slider directly in XAML)
    • Improved command support (to use MVVM !)
    • Advanced text editing control
    • Clipboard API
    • Google Chrome support
    • And lot more…

    - The surface SDK is publicly available for download: http://msdn.microsoft.com/en-us/library/ee804845.aspx

    - Office2010 Beta is available for download: http://www.microsoft.com/france/office/2010/beta/default.mspx

    Many WPF sessions are going to be available for streaming in the next couple of days:

    • How Microsoft Visual Studio 2010 Was Built with Windows Presentation Foundation 4
    • Advanced Windows Presentation Foundation Application Performance Tuning and Analysis
    • Deep Dive into WPF4 Multi-Touch APIs
    • Mastering WPF Graphics and Beyond
    • Windows Presentation Foundation 4 Plumbing and Internals
    • Microsoft Surface: Multi-touch Development Integration with Windows 7 and WPF 4
    • XAML Futures in Microsoft .NET Framework, Microsoft Silverlight and Tools

    If you wan an overview of the incoming new features for WPF4, check out Lester’s blog.

    Another information, not PDC related, about a new very cool WPF data-visualization application made by Microsoft: Pivot.

    pivot

    Check out more information here.

    WP Theme & Icons by N.Design Studio
    Entries RSS Comments RSS Log in