Dec
15
2011

Shortening namespace declarations in XAML files

Vue sur la tête de la femme couchée de la terrasse de la villa cannelleThis afternoon I was working on Innoveo Skye Editor which is a WPF application written in C#.

The application is using Telerik RadControls for WPF.

I was facing the issue of having more and more namespace declarations like the following for RadInput and Rad:

 

<Window x:Class="skyeEditor.View.Dialogs.ProductSettingsDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:RadInput="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input"
        xmlns:Rad="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"

Searching for a solution I thought of ASP.NET in which you can declare in the web.config things like that:

<pages pageBaseType="System.Web.Mvc.WebViewPage">
  <namespaces>
    <add namespace="MyNamespace" />

My goal was to have one namespace declaration for example telerik and be able to use it in all my XAML files without having to declare too much.

So I started an online discussion with Laurent Bugnion who has always shown me the good direction, which in this case is the

XmlnsDefinitionAttribute Class

Followed by an article from Sandino Di Mattia about “A Guide to Cleaner XAML with Custom Namespaces and Prefixes (WPF/Silverlight)”.

Using the idea I was able to add the following to the AssemblyInfo.cs of my own project:

[assembly: XmlnsDefinition("telerik",
                           "Telerik.Windows.Controls",
                           AssemblyName = "Telerik.Windows.Controls")]

[assembly: XmlnsDefinition("telerik",
                           "Telerik.Windows.Controls",
                           AssemblyName = "Telerik.Windows.Controls.Input")]

[assembly: XmlnsDefinition("telerik",
                           "Telerik.Windows.Controls",
                           AssemblyName = "Telerik.Windows.Controls.Navigation")]

[assembly: XmlnsDefinition("telerik",
                           "Telerik.Windows.Controls",
                           AssemblyName = "Telerik.Windows.Controls.RibbonView")]

And then my XAML file declaration looks like that:

<Window x:Class="skyeEditor.View.Dialogs.ProductSettingsDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"

And I can use everywhere for all Telerik RadControls for WPF with the prefix telerik

<telerik:RadComboBox ItemsSource="{Binding ProductNodeLabels}"
                        SelectedItem="{Binding SelectedProductNodeLabel}"
                        Margin="0,0,0,5" />

A little step but a nice improvement!

Nov
12
2011

Fixing ReSharper inspection Results used from XAML

Rocher du diamant depuis la grande anse du diamantFinishing this week sprint I decided to inspect some code using ReSharper 6.1 EAP and I started to give ReSharper a chance to help me find some of broken code.

When I started I had some of the following inspection results. It is clearly showing that some properties wasn’t identified as used in a WPF binding.

So ReSharper proposed to make the property private which for sure was not ok for me has I knew it was used.

Some time ago I started to assign some design DataContext to be able to navigate from View to my ViewModel just by pressing Go to Declaration (CTRL-B in IDEA scheme) in ReSharper.

<UserControl x:Class="skyeEditor.View.StatusBarView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:ViewModel="clr-namespace:skyeEditor.ViewModel"
             mc:Ignorable="d"
             d:DataContext="{d:DesignInstance Type=ViewModel:StatusBarViewModel}">

This for sure helps ReSharper code inspection as you can see on the following screenshot

Now I can navigate from View to ViewModel, can avoid to have developer deleting properties that are sued in XAML bindings, but I can also get an idea of where a ViewModel property is used by using ReSharper Find Usage (Alt-F7). I see right away that the StatusBarView.xaml is using the property ShowActivityProgress.

So don’t forget to add the d:DataContext into your XAML !

Apr
9
2011

Disabling Silverlight addon in IE9 is not such a good idea

The other day I disabled Silverlight add-on in IE9. Don’t ask me why I don’t really remember, and I prefer not.

Several days after that I started an out of the browser application, ClickTime which we use to report our hours. And I got a weird JavaScript error a la IE with a white window and the picture asking me to install Silverlight. I checked that it was still installed and it was, no problem.

Then I uninstalled it and reinstalled it! Same issue.

It took me time to remember that I disabled the Silverlight add-on in IE9 and for sure when I enabled it, then the out of browser applications were working again and I didn’t get anymore this install Silverlight picture.

Dec
1
2009

MVVM Light Toolkit V3 Alpha 3 for WPF4/SL4

Laurent Bugnion just published MVVM Light Toolkit V3 Alpha 3 which support WPF 4 and Silverlight 4!

I published, yesterday a short post in French on my Tech Head Brothers portal about Silverlight 4 Beta, Drop Target et MVVM which shows the usage of this new version of EventToCommand combined with Silverlight 4 Drop Target.

Here is the post of Laurent

4149123651_4bb720be74_o[1] I just published the latest alpha version of the MVVM Light Toolkit. I will post more about the new features in this alpha version, but the most exciting is probably that with this release, the MVVM Light Toolkit works in Windows Presentation Foundation 4 and in Silverlight 4 (in Visual Studio 2010).

There is no automatic installer for this version yet, but I wrote a page describing how to install manually (it is as easy as unzipping a few files). All the features are also available for Visual Studio 2008 as usual.

The source code was also updated on the Codeplex website.

More documentation will follow soon so stay tuned. In the mean time, have fun with MVVM in WPF4/SL4!

Jul
10
2009

Silverlight 3 RTM Released

Microsoft just released Silverlight 3!

You might download Microsoft® Silverlight™ 3 Tools for Visual Studio 2008 SP1 from this page.

Overview

This package is an add-on for Visual Studio 2008 SP1 to provide tooling for Microsoft Silverlight 3. It can be installed on top of either Visual Studio 2008 SP1 or Visual Web Developer 2008 Express with SP1, and it provides a Silverlight project system for developing Silverlight applications using C# or Visual Basic.
This download will install the following:

  • Silverlight 3 developer runtime
  • Silverlight 3 software development kit
  • KB967143 for Visual Studio 2008 SP1
    and/or
    KB967144 for Visual Web Developer 2008 Express with SP1
  • Silverlight 3 Tools for Visual Studio 2008 SP1
    and/or
    Silverlight 3 Tools for Visual Web Developer 2008 Express with SP1

Silverlight 3 Tools for Visual Studio 2008 SP1 includes:
  • Visual Basic and C# Project templates
  • Intellisense and code generators for XAML
  • Debugging of Silverlight applications
  • Remote debugging of Silverlight applications for Mac
  • Web reference support
  • WCF Templates
  • Team Build and command line build support
  • Support for cached transparent platform extensions
  • Support for Silverlight 3 Out-of-Browser applications
Feb
21
2009

Eclipse4SL – Eclipse Tools for Silverlight

This is an interessting video about the plugin eclipse4SL from Soyatec.

This plugin allows Eclipse / Java developers to build RIA with Silverlight and collaboration between Web Designers, .NET Developers and Java Developers.

Jun
15
2008

Silverlight Planning Poker Timer

The other day I was searching for a small project to get started with Silverlight 2 development.

In my today’s works at Innoveo Solutions I am spending quite some time evangelizing about Scrum framework. I found some time ago the Planning Poker Timer by Aslak Hellesøy. That’s definitely looks like a great project to implement with Silverlight 2.

So my goal is as the following:

  1. A full re-implementation of the Planning Poker Timer using Silverlight 2 and C#
    • You can set a different time and precision in the URL. Use a precision of 10 to avoid distracting people
    • Rings a bell and turns the screen red (unless you specify other colours) when time is up
    • Make the colours start at blue, go red at 4 seconds and black at 0 seconds or use your imagination to let people know time is running out
    • You can make the timer restart automatically at a certain time. Hitting the spacebar will also restart the timer (and make all of this text go away)
    • Use it to keep folks focussed on time in other situations - like lightning talks, where you can use these settings
    • Make the text bigger to fill the whole screen. This is CMD+ or CTRL+ in most browsers - or via the menu if you're using IE
  2. Turn the Silverlight Planning Poker Timer to a Vista Gadget

So I fired up Microsoft Expression Blend 2.5 June 2008 Preview and created a first very simple project with two TextBlock and used it in Visual Studio 2008.

After less than one hour I was able to:

  • Set a different time and precision in the URL. Use a precision of 10 to avoid distracting people
  • Rings a bell and turns the screen red (unless you specify other colours) when time is up
  • Go full screen

It is really impressive at which speed you can start to handle a project in Silverlight 2 with some .NET backgound. It was really clever from Microsoft to give the same development environment on the client that you have on the server side.

Jun
15
2008

Deep Earth - Nice usage of Virtual Earth and Silverlight Deep Zoom

This nice project is hosted on Codeplex  and you can have a demo on the following page. And for sure as all project on Codeplex you get full access to the source code.

Jun
14
2008

Silverlight 2 Beta 2 - Unable to start debugging!

Unable to start debugging! The silverlight managed debugging package isn't installed.

If you are facing this issue when you try to debug your Silverlight 2 Beta 2 application from Visual Studio 2008 just extract the silverlight_chainer.exe into a folder and run Silverlight.2.0_Developer.exe from the folder. You even don’t have to quick Visual Studio 2008 during the installation.

I was facing this issue in a little project I started to experience Silverlight 2. It is realted to my today’s great interest Scrum! Wait and see.

About Laurent

Laurent Kempé

Laurent Kempé is the editor, founder, and primary contributor of Tech Head Brothers, a French portal about Microsoft .NET technologies.

He is currently employed by Innoveo Solutions since 10/2007 as a Senior Solution Architect and certified Scrum Master.

Founder, owner and Managing Partner of Jobping, which provides a unique and efficient platform for connecting Microsoft skilled job seekers with employers using Microsoft technologies.

Laurent is awarded by Microsoft since Avril 2002: Most Valuable Professional (MVP).

MVP
Certified ScrumMaster
JetBrains Academy Member

My status

Twitter

Flickr

www.flickr.com
This is a Flickr badge showing public photos and videos from Laurent Kempé. Make your own badge here.

Month List

Page List