posts tagged with csharp

Windows 8 XAML Tips - Async Search Suggestions

By Fons Sonnemans, 22-aug-2012

There are a lot of examples on the web how you can add Search Suggestions to the Search Charm of a Windows 8 Metro application. But all the examples I found only demonstrate how to implement a synchronous version. In this blog I will show you how you can do this also asynchronous. I use this technique to fill my Search Suggestion by calling a web service asynchronous. Something which is very common because your data will problably be stored in the Web/Cloud.


Windows 8 XAML Tips - Settings Demo

By Fons Sonnemans, 10-aug-2012

In my previous blog post I explained how you can use the PaneThemeTransition from the Animation Library to show a task pane. In this blog post I want to use this technique to open my Settings and About task panes from the Settings Charm. I will try to make it easier by introducing a TaskPanePopup helper class.


Windows 8 XAML Tips - Show a task pane

By Fons Sonnemans, 25-jun-2012

You can integrate the look and feel introduced in Windows 8 Release Preview into your Metro style app by using the Animation Library suite of Windows-provided animations. Use of the Animation Library animations provides these benefits:

  • Motions that align to Metro style animation principles
  • Fast, fluid transitions between UI states that inform but do not distract the user
  • Clearer visuals to show the user transitions within an app

One of the animations that are supplied in the Animation Library is the show hide panel animation. You use it to show and hide a panel, which is large edge-based UI such as a custom keyboard or a task pane. This 'Windows Animation (Metro styled apps)' article shows you how you can use the PaneThemeTransition animation class in XAML. The article also contains the video below in which the animation is shown. Sadly there is no code sample how to use it in your XAML/C# application. With this blog I want to fill in the gap. I will explain you how you get the animation as shown in the video.


Windows 8 XAML Tips – Custom Fonts

By Fons Sonnemans, 12-jun-2012

It is time for me to write a series of blog items on writing XAML applications for Windows 8. I plan to write one every two weeks. I hope I can keep up the promise.


MessageBox.Show() in WinRT

By Fons Sonnemans, 12-mrt-2012

I'm currently in the process of converting some of my Windows Phone apps to the Windows 8 Consumer Preview. While doing so I discovered there is no MessageBox.Show() method in WinRT. The alternative is to use the new MessageDialog class. This means I have to rewrite a lot of code which I try to avoid. Therefore I came up with my own MessageBox helper class which mimics the behavior of the WP7 MessageBox. In this post I will demonstrate this, using the following sample application.

Suppose I have the following code in my Windows Phone application:

private void Button1_Click(object sender, RoutedEventArgs e) {
    var result = MessageBox.Show("This is MessageBox", "Title", MessageBoxButton.OKCancel);
    if (result == MessageBoxResult.OK) {
        // do something    
    Button1.Content = result.ToString();

In Windows 8 I would have to rewrite it to the following:


My LicenseManager class for the Windows Phone

By Fons Sonnemans, 25-feb-2011

I have developed a few Windows Phone apps which support a Trial mode. In these WP7 apps I use the static IsTrial property of my LicenseManager class to check if the user is using a paid or trial version. This class uses the IsTrial() method of the Microsoft.Phone.Marketplace.LicenseInformation class if you are running in configuration 'Release' mode. If you are developing and running in configuration 'Debug' mode it will return true if the TRIAL conditional compilation symbol is set in your project properties. This makes it easy to test the Trial mode in your code.


SpiralText in Silverlight 4

By Fons Sonnemans, 31-mei-2010

Blend 4.0 includes a new PathListBox control. In Silverlight 4 you can create your own shapes by deriving from the Path class. I have used these two techniques to create this SpiralText sample.

The Spiral class uses ArcSegment objects to create a spiral illusion. It isn't a perfect spiral but it is good enough for me.

The LayoutPath of the PathListBox is set to the Spiral. The ItemsSource is databound to the TextBox.

You can also select the Font, Color, Font Size, Font Spacing and the number of Spirals.

Get Microsoft Silverlight



By Fons Sonnemans, 09-mei-2010

I have written a Silverlight Minesweepe game in October 2008. I just published an improved version on Silver Arcade which support right mouse click. I implemented it using the following RightMouseTrigger. You can set the SetHandled property to true. This stops the MouseRightButtonDown event from bubbling to it's parent.

I really love Behaviors, Actions and Triggers. I hope you like it too.

public class RightMouseTrigger : EventTriggerBase<Control> {

    protectedoverridestring GetEventName() {



    #region SetHandled Dependency Property


    /// Get or Sets the SetHandled dependency property. 


    publicbool SetHandled {

        get { return (bool)GetValue(SetHandledProperty); }

        set { SetValue(SetHandledProperty, value); }



    /// Identifies the SetHandled dependency property.

    /// This enables animation, styling, binding, etc...


    publicstaticreadonlyDependencyProperty SetHandledProperty =





    #endregion SetHandled Dependency Property

    protectedoverridevoid OnEvent(EventArgs eventArgs) {

        var ea = eventArgs asMouseButtonEventArgs;

        if (ea != null && SetHandled) {

            ea.Handled = true;






CountDown Clock in Silverlight 4

By Fons Sonnemans, 01-apr-2010

A while ago I wrote a FlipClock Silverlight 3 application. I have modified it into a CountDown Clock which you can configure using InitParams. It is written in Silverlight 4 and uses the new Viewbox control to make it scalable. I hope you like it.

You can download the sourcecode from here.

Get Microsoft Silverlight

< object data ="data:application/x-silverlight-2," type ="application/x-silverlight-2"



    <paramname="initParams"value="title=Silverlight 4 RTW,date=2010-04-13 08:00AM-8:00"/>




    <ahref=""style="text-decoration: none">

        <imgsrc=""alt="Get Microsoft Silverlight"

            style="border-style: none"/>


</ object >


Get Microsoft Silverlight


DevDays 2010 Materiaal

By Fons Sonnemans, 01-apr-2010

Zoals beloofd kan je de Presentatie + Demo's van mijn 'Introduction to WCF RIA Services' sessie van de DevDays downloaden. Je dient eerst wel de Northwind database te installeren op localhost\SQLEXPRESS. Het benodigde installatiescript is ook in de ZIP file opgenomen. 


All postings/content on this blog are provided "AS IS" with no warranties, and confer no rights. All entries in this blog are my opinion and don't necessarily reflect the opinion of my employer or sponsors. The content on this site is licensed under a Creative Commons Attribution By license.