views:

15

answers:

1

for example:

I have:

public class MyPage : XXXPage
{
.....

  public class HahaConverter: IValueConverter
{

.........

....
}

}

In my xaml, can I do this:

   <Page.Resources>
        <????:HahaConverter :Key="dateConverter" />
    <Page.Resources>

I just wondering how to get ????. I could not reference myself?

Thanks

A: 

Nested classes will require a fully qualified reference, so you will need to add another xmlns entry to the xaml referencing your parent class namespace. e.g.

xmlns:ValueConverters="clr-namespace:YourAppName.MyPage;assembly=YourAppName"

In VS 2010 once you start typing auto-complete/intellisense should start listing your project namespaces*.

Then reference your value converter with

<ValueConverters:HahaConverter x:Key="dateConverter">

*Note: It is usually recomended to stick to the one-class one-file standard as tools, coders (and VS) cope better. You will likely wind up with a large collection of Value Converters for Silverlight, might as well start a library for them :)

Enough already