Archives / 2010 / December
  • My Windows Phone 7 presentation in Montreal

    altLast week I presented a session as part of the Microsoft Windows Phone 7 Developers Briefing in Montreal. I was with another RunAtServer team member: Louis-Philippe Pinsonneault, who presented the “Phone Games with XNA” part.

    I showed some slides, then built a live WP7 demo with VS2010 that covered:

    • XAML
    • MVVM
    • Design time data
    • Resources
    • Data binding
    • INotifyPropertyChanged
    • Converter
    • MVVM Light Toolkit
    • Blend and behaviors
    • Orientation
    • Accelerometer

    So I created a die roll phone application... that randomize a die value with a roll effect, and added a nice “Shake to roll” feature!

    Thanks for everyone who showed up, it was fun!


    Download the slides

    Download the code


    Thanks to Colin Melia for the slides and code. The Die app code belong to him.
    You can learn more with a great tutorial here:
    My code sample here contains the original code + my “shake to roll” feature (AccelerometerHelper class).

  • The definite guide to Notification Window in Silverlight 4

    Note: This article was first published in Web Central Station, but code format has problem there, so I republish here.
    When this article was written the latest version of Silverlight was Silverlight 4.

    Notification Window is a Silverlight Out-of-Browser feature (among WebBrowser control, Elevated Trust and offline DRM) that allows your application to display a notification as a little pop-out window that disappear automatically. This is sometimes called a “toast”, and is similar to the Outlook live notification when new emails get in your inbox.


    The Notification Window is only available in Out-of-Browser (OOB) mode. You can take advantage of this feature to display confirmation of user’s actions (“Product saved"), application status (“Application updated, please restart”) or warn the user that data were refreshed while he is working on another application.

    Silverlight Notification Window
    Notification Window (”Now Playing”) used in a Silverlight Media Player app.


    How to use the NotificationWindow?

    1. Check if the app is running Out-of-Browser (with App.Current.IsRunningOutOfBrowser)
    2. Instantiate a NotificationWindow object
    3. Set its Height and Width
    4. Set the Content property to something of type FrameworkElement (UserControl, TextBlock, …)
    5. Use the Show() method

    As mentioned on MSDN: “You must set Height and Width on a notification window before Show is called and the notification displays. Attempting to set the height/width of a displayed notification throws an exception.”


    Notification layout

    The typical usage for the NotificationWindow visual is to create a UserControl to serve as the NotificationWindow.Content, so you can design the UI of the notification in Blend. But it could be something as simple as a TextBlock, or you could use a custom control which comes with its whole XAML graph (Canvas, Grid, Button, …) and code.


    Show me the code!

    Code to create a simple Notification:

    Assuming you have a NotificationWindow nw; defined in your class, you could add this code in the click event of a Button:

    // If a notification is already opened, close it
    if (nw != null)
    // Create a new nofitication window
    nw = new NotificationWindow();
    nw.Width = 400;
    nw.Height = 100;
    // Create a new TextBlock
    TextBlock text = new TextBlock();
    text.Text = "Simple Notification";
    text.FontSize = 26;
    text.HorizontalAlignment = HorizontalAlignment.Center;
    text.VerticalAlignment = VerticalAlignment.Center;
    // Set the content of the notification with the TextBlock
    nw.Content = text;
    // Show the notification for 3 seconds



    Code to create a custom Notification:

    if (nw != null)
    // Create a new nofitication window
    nw = new NotificationWindow();
    nw.Height = 100;
    nw.Width = 400;
    // Create a custom control for the Notification UI
    CustomNotification customContent = new CustomNotification();
    customContent.Header = "Custom Notification Header";
    customContent.Text = "This is a custom Notification text.";
    // Set the content of the notification with the control
    nw.Content = customContent;
    // Show the notification for 4 seconds


    The code for the CustomNotification custom control is available with the source code linked below.


    Things you need to know

    Maximum size for a Notification Window is: 400x100px.

    Currently (SL4) a Notification Window does not support transparency (for security reasons), no rounded corners as well.
    You can only style inside the content of the Window with your own control. The notification default to a blank background.

    Multiple notifications:
    You can’t have more than 1 notification at the same time (or you’ll get an InvalidOperationException), and the API does not provide a built-in queue mechanism. But nothing prevent you from building your own system to queue several notifications, and it’s fairly easy, see Tim Heuer post.

    No fade in/fade out like in Outlook right now. No transition/animation possible for the Notification Window itself.

    Silverlight always display the notification in the common location of your OS, on a Windows system it will appear in the lower right corner of the screen, on a Mac it is upper right.

    You can interact with a Notification Window but only with the mouse, no keyboard events. Also you can’t run actions like navigating from a HyperlinkButton, using SaveFileDialog or OpenFileDialog, accessing the Clipboard or switch to full-screen mode.

    The maximum duration for a notification is 30 seconds so that is NotificationWindow.Show(30000).


    Download the code

  • My presentations at the Montreal .NET Community

    altOn Monday I did two presentations at the Montreal .NET Community.

    A quick talk on SQL Server Compact Edition 4 first, then I did a huge demo on Visual Studio LightSwitch.


    Download the slides


    For LightSwitch I advise you to check my ppt from TechDays Canada because I just had 1 slide at the UG...

    Download my LightSwitch demo (LightSwitch beta 1)

  • Activate internet tethering on Samsung Focus with Rogers Canada

    Disclaimer: All this works today (tested on several phones), but might not work tomorrow…

    Warning: After this setup you won’t be able to sync your phone with the Zune software via a cable, only via WiFi. Unless you manually switch back to cable mode (painful). You won’t be able to deploy apps you build with VS2010 as well…

    This setup works for the Samsung Focus phone provided by Rogers Canada carrier.

    Please note this is for educational only, hoping for Microsoft to activate this feature in the near future… Waiting for that I am not responsible for any damage to your computer or phone.


    So here is the setup to activate internet tethering to share your phone’s data connection with your Windows 7 laptop:

    Download and install the drivers on your computer


    Activate the diagnostic menu

    - On the phone go to the keypad and dial ##634# and hit the call button.
    - A diagnostic screen appear with a keypad
    - Dial *#7284# which will bring up the USB Path Control settings (Zune Sync, Modem Tethered Call, and Modem USB Diag)
    - Choose Modem Tethered Call


    Configure the modem

    Start menu, type and select "device manager"
    Click "Modems"
    Verify that the modem is here

    Right click on it / Properties / Advanced
    Then type this for "Extra initialization commands":



    Setup the connection

    Start menu, type "Network and sharing center"
    Set up a new connection
    Choose: "Set up a dial-up connection"
    Enter the following info:
    phone number = *99***1#
    user name = wapuser1
    password = wap


    Disable IP Header Compression

    Right-click on your dial-up connection, click properties and select “Networking” tab


    Properties / Advanced / uncheckUse IP header compression


    That’s all folks!
    so 1996…..

  • Silverlight 5 preview!

    A preview of Silverlight 5 has just been presented at the Silverlight Firestarter event!!


    New Features Announced for Silverlight 5 Beta


    Premium Media Experiences

    Silverlight 5 offers improved media support and rich UI capabilities:

    • Hardware Decode and presentation of H.264 improve performance for lower-power devices to render high-definition video using GPU support.
    • TrickPlay 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.
    • Improved power awareness prevents the screen saver from being shown while watching video and allows the computer to sleep when video is not active.
    • Remote-control support allows users to control media playback.
    • Digital rights management advancements allow seamless switching between DRM media sources.

    Business Application Development

    Silverlight 5 is Microsoft solution for building next-generation business applications:

    • Fluid user interface enables smoother animation within the UI. Inter-Layout Transitions allow developers to specify animations to apply when elements are added, removed or re-ordered within a layout. This provides smoother user experiences when, for example, items are inserted into a list.
    • Text improvements make it possible to build rich magazine-style text layouts:
      –     Multicolumn text and linked text container allow text to flow around other elements.
      –     Tracking/leading set precisely how far apart each character is for full creative control.
      –     Text clarity is improved with Pixel Snapping.
      –     Text layout performance is significantly improved.
      –     OpenType support has been enhanced.
    • Support for Postscript vector printing enables users to create reports and documents, including the ability to create a virtual print view different from what is shown on the screen.
    • Applications can now work the way users expect with added support for double-click and Combobox type ahead.
    • Databinding enhancements allow more work to be done more easily via XAML:
      –     Debugging support now allows breakpoints to be set on a binding, so you can step through binding failures.
      –     Implicit DataTemplates allow templates to be created across an application to support a particular type by default.
      –     Ancestor RelativeSource allows, for example, a DataTemplate to bind to a property on the control that contains it.
      –     Binding in style setters allows bindings to be used within styles to reference other properties.
      –     The DataContextChanged event is being introduced.
      –     Markup extensions allow code to be run at XAML parse time for both properties and event handlers, enabling cutting-edge MVVM support.
    • Networking and Windows Communication Foundation enhancements:
      –      Reduced network latency by using a background thread for networking.
      –      WS-Trust support: message security — encrypted at the Windows Communication Foundation level; Security Assertion Markup Language authentication token.
    • Silverlight 5 performance improvements include these:
      –     Reduced network latency by using a background thread for networking.
      –     XAML parser improvements that speed up startup and runtime performance.
      –     Support for 64-bit operating systems.
    • Graphics improvements
      –     Graphics Processing Unit (GPU) accelerated 3-D application programming interface (API) provides rich graphics on the Web for building advanced data visualizations and rich user experience (UI).
      –     Immediate mode graphics API allows direct rendering to the GPU.
      –     Hardware acceleration is enabled in windowless mode with Internet Explorer 9.
    • Silverlight offers a new class of trusted applications that brings desktop capabilities 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:
      –     Host HTML content as a Web browser control within the Silverlight application. HTML pages, such as help content or e-mail, can be integrated within the application.
      –     Read and write files to the user’s My Documents folder, making it easier to find media files or create local copies of reports.
      –     Launch Microsoft Office and other desktop programs. Users can open Microsoft Outlook and create an e-mail message, or send a report to Word utilizing the power of Office.
      –     Access devices and other system capabilities by calling into application COM components. Users can access a USB security card reader or a bar-code scanner.
      –     Enjoy full keyboard support in full screen, which enables richer kiosk and media viewing applications.
      –     Call existing unmanaged code directly from within Silverlight with P/Invoke.
    • Out-of-browser trusted applications are further enhanced:
      –     Existing unmanaged code can be called directly from within Silverlight with P/Invoke.
      –     Child Window support allows multiple windows to be launched from the application.
    • Tools improvements include these:
      –     Microsoft Visual Studio profiling support including CPU, memory, thread contention.
      –     Visual Studio Team Test support.

    Exciting times ahead!!