views:

127

answers:

2

Hi All, Please forgive the noob question but I'm going round in circles and need answers...

Anyway, I've been looking at this article WPF: How to bind RadioButtons to an enum? but I just can't get the convertor to be recognised within the XAML file.

<Window x:Class="Widget.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit"
    Title="Widget" Height="366" Width="588" WindowStyle="SingleBorderWindow">
    <Window.Resources>
        <EnumBooleanConverter x:Key="enumBooleanConverter" />
    </Window.Resources>
...

I have a seperate file holding the EnumBooleanConverter class but the above reference gives me the following error:

Error 1 The tag 'EnumBooleanConverter' does not exist in XML namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation'.

I've tried adding references to the assembly and then appending the tag to the XAML but to no avail.

<Window x:Class="Widget.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit"
    xmlns:local="clr-namespace:Widget;assembly=Widget"
    Title="Widget" Height="366" Width="588" WindowStyle="SingleBorderWindow">
    <Window.Resources>
        <local:EnumBooleanConverter x:Key="enumBooleanConverter" />
    </Window.Resources>
...

Any help would be greatly appreciated.

A: 

Make sure EnumBooleanConverter is publicly accessible and it has a public empty constructor.

Ray
I thought this may have fixed the problem but when I did a rebuildI still get the error.
TeamWild
A: 

After much head scratching (and a fair amount of shouting at the screen) I have identified the problem.

It turns out that identifying the namespace shouldn't have the assembly.

I was defining it like this

xmlns:local="clr-namespace:Widget;assembly=Widget"

... But it should have just been like this

xmlns:local="clr-namespace:Widget"
TeamWild