How do I format the contents of a DataGrid cell as a Date? as Currency?

Posted by Ben McCormack on Stack Overflow See other posts from Stack Overflow or by Ben McCormack
Published on 2010-03-12T03:10:21Z Indexed on 2010/03/12 3:17 UTC
Read the original article Hit count: 277

Filed under:
|
|
|
|

I have a Silverlight DataGrid that's being populated with different types of data for each column. I'm trying to figure out how to format some of the contents of the DataGrid's cells, specifically for dates and formatting.

I have a date column that's currently displaying like: 3/11/2010 12:00:00 AM. I would rather it display like 3/14/2010.

I have a number column that's currently displaying like: 51.32. I'd rather it display as currency like $51.32.

I'm not sure how I can go about doing this. I'd prefer to do it in XAML instead of C#, but both solutions are fine.


For reference, here's my XAML so far:

    </data:DataGridTextColumn>

        <data:DataGridTextColumn Header="Payee" 
                                 Binding="{Binding Payee}"/>
        <data:DataGridTextColumn Header="Category"
                                 Binding="{Binding Category}"/>
        <data:DataGridTextColumn Header="Memo" 
                                 Binding="{Binding Memo}"/>
        <data:DataGridTextColumn Header="Inflow" 
                                 Binding="{Binding Inflow}"/>
        <data:DataGridTextColumn Header="Outflow" 
                                 Binding="{Binding Outflow}"/>
    </data:DataGrid.Columns>

© Stack Overflow or respective owner

Related posts about Silverlight

Related posts about datagrid