The Design view displays System.Object in a TextBlock when the converter is applied to a number in Blend

In Microsoft Blend for Visual Studio (Express 2013 and Community 2015 RC), I created some sample data with a set of elements consisting of a number and a string.

Data sample

The number amountis associated with TextBlock:

<TextBlock Text="{Binding amount}" />

The numbers are displayed perfectly, except that I want them to be formatted on a string that displays 2 decimal places. Since it is StringFormat not available for Universal Apps , I tried to add a converter that is trying to achieve the same thing:

public class StringFormatConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, string language)
    {
        return string.Format(parameter as string, value);
    }

    public object ConvertBack(object value, Type targetType, object parameter, string language)
    {
        return null;
    }
}

I add a resource for it:

<Page.Resources>
    <ResourceDictionary>
        <local:StringFormatConverter x:Name="StringFormat"/>
    </ResourceDictionary>
</Page.Resources>

I set up the binding TextBlock:

<TextBlock Text="{
    Binding amount, 
    Converter={StaticResource StringFormat}, 
    ConverterParameter='{}{0:f2}'}" />

But when I do this, the view pane displays System.Objectfor each amount.

, toString(), ! Number.

Blend?

+4
1

, , ? "Text" TextBlock , .

0

All Articles