• Capture usage information of a Windows Phone 7 application using Google Analytics

    About half a year ago I created a Blend behavior to capture usage information of a Silverlight application. But what’s next, in the near future we will have Windows Phone 7, and we can write very nice applications by using the Silverlight platform. Although the platform is the same, you won’t be able to make use of the Blend behavior I’ve written before. Because this Blend behavior makes use of scripting inside the hosting html page. There simply is no page that hosts your Silverlight application. This is a similar problem we face when a Silverlight application is running out-of-browser, but back to the phone. Solution Direction To connect to Google Analytics I need to have a html page that contains a script that calls into Google Analytics to track events. So somehow I need to connect a Windows Phone 7 app to this html page. Solution Implementation I started off with the html page, and made it as small as possible, no content, only the scripting part.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Windows Phone 7 - Application Tracking</title>
        <script type="text/javascript">
            var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
            document.write(unescape("%3Cscript src='" ...

    Full story

    Comments (1)

  • How to improve the Windows Phone 7 Licensing development experience?

    Microsoft really helps developers to implement licensing for your application. First of all everyone has probably read: “an app can only be installed through the Marketplace”. But beside this installation, an application can be tried through the Marketplace. The developer doesn’t have to write complex licensing mechanisms based on RPN strings. If you want to have limited features when the app is in Trial, it’s just one small piece of code. First reference the correct library. The the code is really simple.
    LicenseInfo licenseInfo = new LicenseInfo();
    if(licenseInfo.IsTrial())
    {
        //Limit the application in some way
    }
    Yes that’s all. But how does this code behave? As far as I’ve understood so far, in the final version the IsTrial will check the license with the Marketplace. Right now the behavior is just returning “true”, so that doesn’t help our development, we can’t influence this result in any documented way right now. So I was thinking about possible solution, and remember the Conditional Compilation Symbols. Step 1: Create a New Solution Configuration Make sure that you use Copy settings from “Debug” and “Create new project configurations”. Step 2: Change Project Properties Add a Conditional Compilation Symbol, for example: “FULL_VERSION” Step 3: Use this ...

    Full story

    Comments (0)

  • How to select a ListItem on Hover

    I’ve been experimenting with the PathListBox and wanted to create a better experience for selecting an item in the ListBox. The standard way to select an item in a ListBox is by clicking on it, but in some situations you want to select an item by just hovering over the item. I explicitly say some situations, because I wouldn’t want to fire up the discussion that hovering over an item isn’t the same as explicitly clicking on an item to select it. First requirement for me was to have something that didn’t require me any coding when I want to apply it more than once. So for me the idea of writing a Behavior or TriggerAction does make sense. Second requirement, should work any any regular ListBox but also on the PathListBox. Third, should work with data binding. Setting up the structure So I started creating a Behavior that can be associated with any FrameworkElement and could be applied in the DataTemplate for example. You have to reference the System.Windows.Interactivity assembly to start.
    public class SelectElementOnHover : Behavior<FrameworkElement>
    {
        protected override void OnAttached()
        {
            AssociatedObject.MouseEnter += AssociatedObject_MouseEnter;
        }
    
    
        private void AssociatedObject_MouseEnter(object sender, MouseEventArgs e)
        {
                ...
        }
    
        protected override ...

    Full story

    Comments (0)

  • Trying to sketch a Windows Phone 7 application

    Yesterday Microsoft made all the development tools for Windows Phone 7 available. The development tools are a combination of Visual Studio and Blend. Since the introduction of Blend 3 and it’s extra tool Sketchflow, I’m really fond of making prototypes. So the first thing I did when I installed all the Windows Phone 7 tools, is look for a Windows Phone Sketchflow project. There are only two types of projects: Windows Phone Application and Windows Phone Data-drive Application (MVVM). Sadly no Sketchflow project. So let’s look at how we could hack, to get our a Sketchflow Windows Phone project. A Windows Phone Application with a Sketchy style I first created a Windows Phone Application and wanted to see if it is possible to include the Silverlight Sketch styles. The Silverlight Sketch styles are included in the Microsoft.Expression.Prototyping.SketchControls.dll which can be found in C:\Program Files (x86)\Microsoft SDKs\Expression\Blend\Silverlight\v4.0\Libraries. Also from another SketchFlow project I copied SketchStyles.xaml, where I had to remove all the TabPanel, TabItem related styles, because they aren’t support by Windows Phone. Similar for the ScrollViewer control, where the compiler was complaining as well. Next step was to make use of one of the styles, to see if it ...

    Full story

    Comments (0)

  • MeXperience – Step 3 – Architecture, implementing pipes and filters

    In step 2 I explained about the Architecture of MeXperience I had in mind. This article explains the implementation of the pipes and filters pattern to filter the list of experience objects. I will start to tell that my implementation is based on an article from Oren Eini. The Filter In MeXperience there are currently only two types of filters: by tag and by role. But I could think about others like a filter by year of experience. The idea of the filter in the pipes and filters patterns is to have a simple operation, and a lot of combine simple operation in one pipeline make a complex operation. My filters are also used as objects to represent an item in the TagCloud. This is my base.
    public abstract class CloudItem
    {
        public CloudItem()
        {
            Weight = 1;
        }
    
        public int Weight { get; set; }
        public string Name { get; set; }
    
        public abstract IEnumerable<Experience> Filter(IEnumerable<Experience> experiences);
    }
    
    Yes I know it’s abstract and there’s no filter implementation. First the signature, there’s an enumeration of experiences coming as input, and there’s an enumeration as output. Let’s see one of the implementations, the of CloudItemTag.
    public class CloudItemTag : CloudItem
    {
        public ...

    Full story

    Comments (2)

  • Capture usage information of a Silverlight application using Google Analytics and a Blend Behavior

    It’s already more than a year ago since Tim Heuer published his article on Event tracking in Silverlight. Since that time we’ve got Silverlight 3 and Silverlight 4 beta. So it’s time for a different implementation that can even be used by non-coders. This article will make use of Silverlight 4 beta, but in the end almost everything works on Silverlight 3 as well. The idea Create an Expression Blend Behavior that does all the tracking for me! The implementation – Some Javascript Blend Behaviors are extremely easy to use. Designers can use them without having knowledge on code and besides that they don’t dirty the business flow of the code. Also Behaviors can be used very easily in combination with DataTemplates and BindingExpressions. Let’s start with the very beginning. On the html-page there needs to be some Javascript from Google Analytics to start the Analytics script.
    <script type="text/javascript">
      var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    </script>
    <script type="text/javascript">
      try{
        var pageTracker = _gat._getTracker("UA-xxxxxx-x");
        pageTracker._trackPageview();
      } catch(err) {}
    </script>
    This is the generic Google Analytics script to start the normal tracking. Please make sure that you replace xxxxxx with your own Tracking Code ...

    Full story

    Comments (0)

  • MeXperience – Step 2 – Architecture and more

    Besides the purpose of the application itself, I want to make sure I expand my knowledge on Silverlight. This would be especially on the architecture of Silverlight applications. Architecture - MVVM I’ve read quite a lot of articles on MVVM, but there weren’t many article series that were as complete as the series on RIA, MEF and MVVM by Shawn Wildermuth (1,2,3,4). I have no intend to write an article or series on MVVM because it’s not really in my fingers yet. But to know more on MVVM please read the fantastic series by Shawn. But then again my intend is to make use of MVVM for MeXperience. The idea is to introduce two ViewModels (please let me know if you’d advice a different setup for ViewModels). 1. The ExperienceFilterViewModel, which supports showing all experience-tags and the ability to form a filter. 2. The ExperienceViewModel, which has control over all experience-parts that are found in the data store and can interact independent from the filter but can have filters applied as well. Because I chose to use the articles by Shawn as my knowledge base for MVVM, I will make use of ...

    Full story

    Comments (0)

  • MeXperience – Step 1 – Idea + Prototype

    Every now and then I have some ideas. That’s also the main reason why I created a Windows Mobile application to support at least the storage of my ideas to be sure that those ideas don’t get lost. Some ideas will never be more than just an idea. One of my latest ideas was the below idea. I want to implement this idea, in the time I have (very little). MYdea: MeXperience I want application that can show my work experience in an interactive way. I was thinking tag-cloud, tiles, details, photo. Yes a tag-cloud with the different technologies and roles that have been covered in the experience. If you would click on any item in the tag-cloud, it would be part of the filter. The filter would be applied to the experience. I wanted to show blocks of experience, to offer a different experience than what people are used to in common curricula vitae. And when you click on a block, the details of the block would be shown. Maybe more features would be appear in the future, but this is it for now. Prototype So what I did was, start with Sketch Flow. Sketch Flow is my favorite ...

    Full story

    Comments (0)

  • Silverlight 4 – Credentials, we’ve got it!

    I’ve been writing on Credentials in context of Silverlight for some time now. I didn’t like the options that were available to secure services and allow integration with Silverlight. For some history search for “credentials” on my blog. July 2008 – Silverlight 2 – A series of articles on possible (failed) work-arounds for getting Credentials in Silverlight. March 2009 – Silverlight 3 – WebClient, WebRequest and WCF calls using Credentials? July 2009 – Silverlight 3 – Did we get support for Credentials?   In Silverlight 3 we already got the property Credentials on both WebClient and WebRequest. But sadly there still was no implementation available. After the launch of Silverlight 3 Tim Heuer already commented that the feature for credentials was being considered for future versions. Very nice, specially because we finally got it in Silverlight 4 (beta). Support for Credentials has come to the ClientHttp stack, so you must make sure you register the http prefix to be using ClientHttp stack.
    WebRequest.RegisterPrefix("http://", System.Net.Browser.WebRequestCreator.ClientHttp);
    Besides that we also need to make sure that we set the property UseDefaultCredentials to false. Depending on whether you make use of a WebRequest or use a WebClient it will look like this.
    request.UseDefaultCredentials = ...

    Full story

    Comments (2)

  • Silverlight 3 – Local Messaging Explained + Enhancement

    One of the new features Silverlight 3 introduced is called Local Messaging. This feature supports communication between different Silverlight applications that are running on the same client. This is particular useful in areas like Sharepoint where you offer different parts to be positioned at all places on the screen. It’s possible to even communicate between two Slverlight applications running on different domains. For example one app is running on maindomain.com and the second app is running on maindomain.nl or even more different. The Local Message API is very easy to use. But let’s first setup the Proof of Concept environment. I created a solution with two Silverlight Applications (SUILeft and SUIRight), a hosting project (Web) and a fourth project which is a Silverlight Class Library, we will come to that soon. I combined both the “Left” and “Right” applications in one html page, like this (please remind to change the paths according to your setup).
    <div id="silverlightControlHost">
        <object data="data:application/x-silverlight-2," type="application/x-silverlight-2"
            width="40%" height="100%">
            <param name="source" value="ClientBin/MM.Silverlight.SUILeft.xap" />
            <param name="onError" value="onSilverlightError" />
            <param name="background" value="white" />
            <param name="minRuntimeVersion" value="3.0.40624.0" />
            <param name="autoUpgrade" value="true" />
            <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0" style="text-decoration: none">
                <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight"
                    style="border-style: none" />
            </a>
        </object>
        <object data="data:application/x-silverlight-2," type="application/x-silverlight-2"
            width="40%" ...

    Full story

    Comments (0)

  1. 1
  2. 2
  3. Next page