StringFormat error

Oct 14, 2008 at 11:20 PM
Even though the following code compiles and runs fine, it fails to load in the designer. Is it just me or there is a known bug in DataGrid?

<dg:DataGrid.Resources>
    <DataTemplate x:Key="PnlResource">
        <TextBlock Text="{Binding Pnl, Mode=OneWay, StringFormat={}{0:N2}}" HorizontalAlignment="Center" />
    </DataTemplate>
</dg:DataGrid.Resources

There are 3 errors when I try to load the designer:
Error    1    Expected ''.   
Error    2    Expected '='.   
Error    3    The property '' was not found in type 'Binding'.   

Oct 15, 2008 at 5:52 PM
I had a similar issue, this seems to make the designer and runtime happy:

<dg:DataGridTextColumn Header="My Header" DataFieldBinding="{Binding myDate, StringFormat='{}{0:MM/dd/yyyy}'}" />

Cheers,
Jon
Oct 15, 2008 at 11:57 PM
Hi Jon,

Quotes helped indeed. Thanks!!!

Cheers,
Boris
Oct 16, 2008 at 6:00 PM
Hi Boris - I'm not sure if that is how it is "supposed" to work.  Honestly I just hacked it in there when I had the issue, and it works :)