locked
StringFormat doesn't give me the results that I would like. RRS feed

  • Question

  • I am binding to a datasource that has a property of type decimal that I would like to display as money ($ and two decimal places). When I put the following XAML in:

              <DataTemplate x:Key="PriceStyle" >
                <TextBlock ToolTip="{Binding Path=Price}" VerticalAlignment="Center" Margin="2" Padding="2" Text="{Binding Path=Price, StringFormat={}{0:C2}}" />
              </DataTemplate>
    

     

    I only get the '$' and zero decimal places. I have tried StringFormat={}{0:C} and I get the same result. Any idea on how I can get 2 decimal places?

    Thank you.

     

    Thursday, May 20, 2010 9:49 PM

Answers

  • I tested your snippet and it works fine both StringFormat={}{0:C} and StringFormat={}{0:C2}.
    • Marked as answer by KevinBurton Sunday, May 23, 2010 11:44 PM
    Sunday, May 23, 2010 5:17 AM