I thought it should be a simple thing for WPF, but I can't make it work... I have an int property (Divisions) on my class and I want to bind it to a DataGrid column.
<DataGrid AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTextColumn Header="Number of Divisions" Binding="{Binding Path=Divisions, StringFormat={}\{0:N0\}}" IsReadOnly="True"/>
</DataGrid.Columns>
</DataGrid>
However, it doesn't show up. I also tried this code and it doesn't work for me either:
<DataGrid AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTemplateColumn Header="Divisions" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Divisions, StringFormat=C}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
For testing purpse, if I add a string property to this class to return string value of Divisions, it just works fine. So, what's wrong here?