Search code examples
visual-studio-2012expression-blendwindows-phone-8

IValueConverter not working in VS2012-Blend for win 8


I'm using VS 2012 and Blend for windows 8. When I use to use Converters in my Windows Phone and Silverlight apps I would click on new convert and picked my converter from the list. Now that I have upgraded to VS 2012 and Blend for windows 8 none of my custom converts are showing up. Anyone know how to find the converters?

 class Class1 : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        throw new NotImplementedException();
    }

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

Solution

  • 've never done it the way you posted in the comment (do you have a reference to your converter namespace?), however this works. Add a reference to your converter namespace ontop of your .xaml:

    xmlns:converters="clr-namespace:Appname.Views.Converters"
    

    Then declare the converter:

    <phone:PhoneApplicationPage.Resources>
        <converters:SavedTrackColorConverter x:Key="SavedTrackColorConverter" />
    </phone:PhoneApplicationPage.Resources>
    

    Then use the converter where desired:

    <TextBlock Foreground="{Binding ListboxStringSavedTunes, Converter={StaticResource SavedTrackColorConverter}}" Text="{Binding ListboxStringSavedTunes}"/>