Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
180
Formatting Columns for Currency, Date, etc.
posted

I have looked around but I can't find a solution that either works or specifically answers my question.  I have a simple datagrid setup to display data from a List<T>.  One of the columns is a currency value stored as a Decimal and one is a DateTime object. 

The date looks ok but I want to drop the time from the end of it.  The decimal is just a decimal.  I want it to show comma's for every 3 digits and I only want two decimal places (it currently shows about 8 I think).

I have tried a number of approaches including setting the Coverter however while the coverter code is being called and is converting values (I checked) the column is empty whenever I use this.

It seems to me this should be a lot simpler, a simple StringFormat parameter perhaps?  What am I missing here that is making this so difficult?

Here is the xaml:

<igDP:XamDataGrid x:Name="RepTakeDataGrid" DataSource="{Binding RepTakeDataSource}" Theme="Office2k7Blue" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling">
                    <igDP:XamDataGrid.FieldLayoutSettings>
                        <igDP:FieldLayoutSettings AutoGenerateFields="False" HighlightAlternateRecords="True"
                                                  AllowAddNew="False" AllowDelete="False" />
                    </igDP:XamDataGrid.FieldLayoutSettings>
                    <igDP:XamDataGrid.FieldLayouts>
                        <igDP:FieldLayout >
                            <igDP:FieldLayout.FieldSettings>
                                <igDP:FieldSettings AllowSummaries="True" CellClickAction="SelectRecord" ExpandableFieldRecordHeaderDisplayMode="DisplayHeaderOnlyWhenExpanded" />
                            </igDP:FieldLayout.FieldSettings>
                            <igDP:FieldLayout.Fields>
                                <igDP:Field Name="Amount" Label="Take Amount ($)"   Converter="{StaticResource formatConvertor}" ConverterParameter="'{0:C2}'"  />
                                <igDP:Field Name="EntryAccount" Label="Entry Account"/>
                                <igDP:Field Name="SplitAccount" Label="Split Account" />
                                <igDP:Field Name="RepNumber" Label="Rep #" />
                                <igDP:Field Name="RepName" Label="Rep Name" />
                                <igDP:Field Name="DateReceived" Label="Date" />
                                <igDP:Field Name="RepCodeString" Label="Rep Code" />
                                <igDP:Field Name="ClientName" Label="Client" />
                                <igDP:Field Name="PolicyNumber" Label="Policy #" />
                                <igDP:Field Name="EntryType" Label="Type" />
                            </igDP:FieldLayout.Fields>
                        </igDP:FieldLayout>
                    </igDP:XamDataGrid.FieldLayouts>
                </igDP:XamDataGrid>

Also if you notice anything else wrong with this approach please let me know.

 

Thanks,

Chris

Parents Reply Children
No Data