• Make use of WCF FaultContracts in Silverlight clients

    I think every Silverlight developer has seen at least once, an exception showing a message “The remote server returned an error: NotFound” while connecting to a WCF Service. Alright, that message could have been a better message, but why are we getting this message? Yes, you probably figured that out yourself, something is wrong with your WCF Service, and it’s not a missing WCF Service. Yes it feels something is seriously wrong, why do we get this strange NotFound message? If anything goes wrong, the WCF Service returns some data, but also sets the HTTP Status code to 500. The browser HTTP stack doesn’t allow to read the data when the HTTP Status code is 500. Solution 1: There’s an easy solution to solve this: Don’t use the browser HTTP stack but the client HTTP stack instead. Just a matter of adding the below line of code in the Application_Startup method in the App.xaml.cs.
    WebRequest.RegisterPrefix("http://", WebRequestCreator.ClientHttp);
    Solution 2: Because sometimes you don’t want to make use of the client HTTP stack but rather like the browser HTTP stack there’s a solution for that as well. If you’re using the browser HTTP stack you’ll get things like Windows Authentication and automatic ...

    Full story

    Comments (8)

  • How to cancel the closing of your Silverlight application (in-browser and out-of-browser)

    It’s almost two years ago when I wrote about the concept of canceling the the closing of a Silverlight application. In that era I was only trying to solve the problems that exist inside the browser. Like someone who accidently closes the tab, or types a new url in the tab of the Silverlight application. These things aren’t always a problem, but in Line of Business applications you would at least want to warn the user when he has unsaved data on the screen he’s about to close. Nowadays we have Silverlight applications that run both in the browser and out-of-browser on the desktop. Of course some features can be different between the two versions of the application. But my intend is to have at least a feeling that 100% of the features are equal. So I want to give my users a warning when they are exiting the application, either in-browser or out-of-browser. Even more, I want the warning to be much similar. I want a simple message to be shown automatically. So let’s implement the ICloseHandler
    public interface ICloseHandler
    {
        string Message { get; set; }
        void Initialize();
    }
    Out of Browser Although it might sound like a difficult ...

    Full story

    Comments (4)

  • Solving 3 problems with the ShellTileSchedule

    Are the problems with the Shell Tile Schedule? Yes there are, at least I’m in the impression that there are some problems. Although we have those problems I really like the ShellTileSchedule because it enables an app to have an updated tile without the requirement to write server-side code to notify the client for a new tile. The smallest schedule that’s supported is 1-hour. In that situation every hour the tile will be updated with a tile located on the web (static url, which can return a dynamic image of course). There are three problems I identified so far. 1. You can’t get the status of the ShellTileSchedule. Worse, although you started the schedule it might be stopped because for whatever reason (ex. phone is on Airplane mode) the downloading of the tile failed. 2. You have to wait at least 1 hour before the tile is updated for the first time. 3. After you stopped the ShellTileSchedule, the tile will be the last downloaded tile forever. It would be better if automatically the original tile (from the .xap package) is put back. Combined a diagram to show the problems. Solution 1 for problem 1 Alright, we can’t get the ...

    Full story

    Comments (4)

  • Trigger a Storyboard on ViewModel changes

    Interactions based on ViewModel changes are easy as soon as you understand how it works. A lot of people have been hiding and showing elements in the UI based on a boolean in the ViewModel which is converted to fit the Visibility property. Of course they used an IValueConverter that translates a bool to a Visibility enum. But sometimes designers are tough, they don’t want to show and hide, they want to play a full animation. Of course I know about the ability to trigger a Storyboard by using EventTriggers (control Loaded or Clicked for example). But did you know about the DataTrigger? DataTrigger The DataTrigger comes Expression Blend, you’ll have to reference the Microsoft.Expression.Interactions library, which can be found here: C:\Program Files (x86)\Microsoft SDKs\Expression\Blend\Silverlight\v4.0\Libraries\Microsoft.Expression.Interactions.dll It’s not really that complex to use. If you only want to start a Storyboard when a specific value is put in the bound property the binding looks very much like this.
    <Grid x:Name="LoginGrid">
    	<i:Interaction.Triggers>
    		<ei:DataTrigger Binding="{Binding IsLoggedIn}" Value="true">
    			<ei:ControlStoryboardAction x:Name="FadeOutOnLogin" Storyboard="{StaticResource LoginFadeOut}"/>
    		</ei:DataTrigger>
    	</i:Interaction.Triggers>
    </Grid>
    Operators If you have something more specific where you want to use an operator other than equal it will be just a little bit different. The below only starts the storyboard when ...

    Full story

    Comments (4)

  • Sixin event 9th of November

    Yesterday evening we’ve had another Sixin event. Thanks for Macaw for being our host of the evening. We started with a very interesting session about designers and developers working together by Marc Jacobi, Michel Heijman and Antoni Dol. Quite a few interesting details about their architecture revealed. After the break we’ve had 3 short 20 minute sessions about experiences with Windows Phone 7. First part by Galina Slavova. The second part was presented by me, download the slide-deck here, where I shared my platform experiences in developing the Buienradar.nl application for Windows Phone 7. The third part was presented by Koen Zwikstra, who showed some parts of the new upcoming version of Silverlight Spy with support for Windows Phone 7.

    Full story

    Comments (4)

  • 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 (35)

  • 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 (11)

  • 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 (13)

  • 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 (11)

  • 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 (730)

  1. 1
  2. 2
  3. Next page