Contents tagged with Expression Blend

  • Why I’m Excited About Windows 8

    I don’t consider myself a “fanboy” of any particular company even though my consulting and training business focuses on Microsoft technologies. A "fanboy" is someone that sides with a particular company regardless of how good or bad something is. I go with what I feel is best regardless of company. The .NET framework is my preference for developing Web and desktop applications and Visual Studio is untouchable as an integrated development environment in my opinion. iPad is my preference for a tablet, iPod for a music player, and Android for a phone (although I’d love to replace my Android device with a Windows Phone 7 device since I love the WP7 interface - Sprint still doesn’t have any WP7 devices that I like unfortunately).

    Read more...

  • Maximizing Productivity with the Visual Studio 2010 Silverlight Designer

    Developing Silverlight applications has always been something I've enjoyed. I'm a big fan of the data binding engine that the framework provides and like the flexibility that XAML provides for building user interfaces. With all of the benefits Silverlight provides, the process of developing Silverlight applications hasn't always been as smooth as it could be especially if you relied solely on Visual Studio in the past. Silverlight 2 provided a read-only Visual Studio designer that didn't provide much in the way of functionality while Silverlight 3 only allowed XAML to be edited directly in the editor. Developers using Expression Blend weren't affected by Visual Studio designer limitations much while those without it ended up creating a lot of XAML by hand.

    Read more...

  • Silverlight 4 Code Demos from the Microsoft TechReady Workshop

    I had the opportunity to give a 1-day workshop covering new Silverlight 4 features at the TechReady conference on Microsoft’s Redmond campus this weekend and wanted to post some of the sample code shown for the people who attended and anyone else who’s interested. The workshop was based on the free Silverlight LOB course Microsoft put together which has a lot of detailed lab exercises and videos available if you haven’t seen them. The demo code covers many of the topics detailed in the What’s New in Silverlight 4 whitepaper that John Papa put together.

    Read more...

  • Making Silverlight 3 Application Code More Compatible with Blend

    Expression Blend 3 is a great tool for creating Silverlight or WPF user interfaces using design time tools and controls.  If you haven’t tried version 3 you’re really missing out since it adds a ton of new time-saving features.

    While I really enjoy working in Blend, one of the things I’ve struggled with in the past is making code work better in Blend.  If you’ve ever had an error like the following you know what I mean:

    image

    What’s up with the error?  In short, I’m declaratively assigning my ViewModel object (my object that contains the data being bound to the Silverlight View if you’re new to the whole MVVM terminology) in the View’s resources area as shown next:

    <navigation:Page.Resources>
        <viewModel:PayrollSummaryViewModel x:Key="ViewModel" />
    </navigation:Page.Resources>

    There’s nothing wrong with that except that when the ViewModel object’s constructor is called an error is occurring due to a null reference exception.  Note: Some people like the declarative way of defining ViewModels and some people don't.  A few months ago I was against that approach until I started working on my current project and realized that the pros outweighed the cons (at least for my scenario).  Plus, the declarative approach is used when working with test data in Blend 3.  Ultimately each application has different requirements so I'll leave it as an "exercise for the reader" to decide what works best for you.

    Here’s the code in the constructor which is calling out to a WCF service to retrieve some data:

    public PayrollSummaryViewModel(IServiceProxy proxy)
    {
        _Proxy = (proxy != null) ? proxy : new ServiceProxy();
        GetPayrollSummary();
    }

    You obviously can’t call out to a WCF service when you don’t have access to an HTTP stack.  Fortunately, fixing the problem and making the code more “Blendable” is easy.  Silverlight has a class named DesignerProperties that can be used to check if the code is being run in a designer such as Blend or if the code is being run live.  Here’s an example of using the DesignerProperties class and wrapping it in a property named IsDesignTime:

    public bool IsDesignTime
    {
        get
        {
            return DesignerProperties.GetIsInDesignMode(Application.Current.RootVisual);
        }
    }


    To avoid trying to call the WCF service in the ViewModel object’s constructor when the code is run in Blend I can wrap the code with the call to IsDesignTime as shown next and Blend is happy with everything. 

    public PayrollSummaryViewModel(IServiceProxy proxy)
    {
        if (!this.IsDesignTime)
        {
            _Proxy = (proxy != null) ? proxy : new ServiceProxy();
            GetPayrollSummary();
        }
    }


    You can see that creating more “Blendable” code is pretty easy once you know this simple trick.  More info on the DesignerProperties class can be found here if you’re interested.  There are apparently some issues using it with the Visual Studio designer used for Silverlight 2, but since Silverlight 3 doesn’t have a Visual Studio designer that’s kind of a moot point.

    Read more...

comments powered by Disqus