views:

269

answers:

1

Hi, all.

I'm trying to declare a resource in a WPF UserControl, and I'd like the resource to be an instance of a private inner class. How do I do this?

XAML:

<UserControl ...>
    <UserControl.Resources>
        <local:MyConverter x:Key="MyConverter" />
    </UserControl.Resources>
</UserControl>

Code Behind:

public partial class MyUserControl : UserControl 
{
    private class MyConverter : IValueConverter 
    {
        // convertion code...
    }
}
+1  A: 

You can't do it if the class is private, you could make it internal instead

Regarding the declaration of an inner class in XAML, you should have a look at this discussion

Thomas Levesque
Thanks, I'll take a look.
matheus.emm