I have two decimal datatype columns; I want them displayed like so:

  • Column 1 (ColumnWithNoDollarSign) will have no "$" sign in front of the values
  • Column 2 (ColumnWithDollarSign) will have a "$" sign in front of the values

This is what my XAML currently looks like:

<ig:XamDataGrid Name="xamDataGrid"                        
                IsGroupByAreaExpanded="False"
                DataSource="{Binding Rows, Mode=OneWay}">
    <ig:XamDataGrid.Resources>
        <Style TargetType="{x:Type Editors:XamNumericEditor}">
            <Setter Property="HorizontalContentAlignment" Value="Left" />
            <Setter Property="FontSize" Value="12" />
        </Style>
        <Style TargetType="{x:Type Editors:XamCurrencyEditor}">
            <Setter Property="HorizontalContentAlignment" Value="Left" />
            <Setter Property="FontSize" Value="12" />
        </Style>
    </ig:XamDataGrid.Resources>
    <ig:XamDataGrid.FieldLayoutSettings>
        <ig:FieldLayoutSettings AutoGenerateFields="False"/>
    </ig:XamDataGrid.FieldLayoutSettings>
    <ig:XamDataGrid.FieldLayouts>
        <ig:FieldLayout Key="layout">
            <ig:Field Name="ColumnWithNoDollarSign" Label="Column 1"/>
            <ig:Field Name="ColumnWithDollarSign" Label="Column 1"/>
        </ig:FieldLayout>
    </ig:XamDataGrid.FieldLayouts>
</ig:XamDataGrid>

The problem, as I see it, is that the XamCurrencyEditor style I am applying is overriding all decimal columns. I only want it to override one of the decimal columns. How would I go about doing this?

1

There are 1 answers

0
Gavin Coates On BEST ANSWER

Does the XamNumericEditor represent the format without the $? If so, can you not just specify the style used by each column, ie do:

<ig:XamDataGrid.FieldLayouts>
    <ig:FieldLayout Key="layout">
        <ig:Field Name="ColumnWithNoDollarSign" Label="Column 1" Style="{StaticResource XamNumericEditor}"/>
        <ig:Field Name="ColumnWithDollarSign" Label="Column 1" Style="{StaticResource XamCurrencyEditor}"/>
    </ig:FieldLayout>
</ig:XamDataGrid.FieldLayouts>

Although I would recommend moving all style info to a single file, such as App.xaml, rather than re-defining it in multiple places.