StringFormat error

Oct 15, 2008 at 12:20 AM
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?

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

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 6: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}'}" />

Oct 16, 2008 at 12:57 AM
Hi Jon,

Quotes helped indeed. Thanks!!!

Oct 16, 2008 at 7: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 :)