May 23 2009

Silverlight 2.0: usage of the converters from external assembly in app.xaml

Hi all,

it is my first post and I'd like to strat it from a small trick for defining value converters in app.xaml file in silverlight project.

Problem:

If you define Converters in app.xaml (see below) then you find that Visual Studio designer fails to render User Controls (Visual Studio designer become blank).

<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:myconverters="clr-namespace:MyCustomConverters;assembly=
MyCustomConverters"
             x:Class="ConverterInAppXaml.App"> 
    <Application.Resources>
        <ResourceDictionary >
            <myconverters:MyCustomTextConverter x:Key="myTextConverter"/>
        </ResourceDictionary>
    </Application.Resources>
</Application>

Upd: not the converter defenition in app.xaml file cause the visual studio designer to go blank but xmlns defenition.

Solution:

To avoid this designer problem move namespace declaration closer to usage:

<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             x:Class="ConverterInAppXaml.App"> 
    <Application.Resources>
        <ResourceDictionary xmlns:myconverters="clr-namespace:MyCustomConverters;
assembly=MyCustomConverters"
>
            <myconverters:MyCustomTextConverter x:Key="myTextConverter"/>
        </ResourceDictionary>
    </Application.Resources>
</Application>

 

Voila!!! now designer work perfect and able to render our content.

Comments

5/29/2009 1:12:41 PM
trackback
Silverlight usage of the converters from external assembly in app.xaml

You've been kicked (a good thing) - Trackback from DotNetKicks.com
6/19/2010 7:20:25 AM
pingback
Pingback from lnmykys.com

Prueba de post | Marketing Online

Add comment


(Will show your Gravatar icon)

biuquote
  • Comment
  • Preview
Loading