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
125
XamNumericEditor display $
posted

I'm using the XamNumericEditor bound to a decimal property of an object within the Grid and it always displays the currency symbol $ when editing.

I've added a format of "######.######' so that the display value does not show the $, but I would like this behavior also in edit mode..

If I bind it to a double it works fine, but I need to use the decimal value.

 <DataPresenter:XamDataGrid x:Name="MyGrid" Margin="0,53,0,0">
            <DataPresenter:XamDataGrid.FieldLayoutSettings>
                <DataPresenter:FieldLayoutSettings AutoGenerateFields="False" HighlightAlternateRecords="True"/>
            </DataPresenter:XamDataGrid.FieldLayoutSettings>

            <DataPresenter:XamDataGrid.FieldLayouts>
                <DataPresenter:FieldLayout>
                    <DataPresenter:FieldLayout.Fields>
                        <DataPresenter:Field Name="Commodity" Label="Commodity">
                            <DataPresenter:Field.Settings>
                                <DataPresenter:FieldSettings AllowEdit="false" CellWidth="80" LabelWidth="100" AllowGroupBy="false"/>
                            </DataPresenter:Field.Settings>
                        </DataPresenter:Field>
                        <DataPresenter:Field Name="Volume" Label="Volume Increment">
                            <DataPresenter:Field.Settings>
                                <DataPresenter:FieldSettings AllowEdit="true" CellClickAction="EnterEditModeIfAllowed" CellWidth="100"
                                                             LabelWidth="100" AllowGroupBy="false" EditorType="{x:Type Editors:XamNumericEditor}">
                                    <DataPresenter:FieldSettings.EditorStyle>                                       
                                        <Style TargetType="{x:Type Editors:XamNumericEditor}">
                                            <Style.Setters>
                                                <Setter Property="ValueType" Value="{x:Type System:Decimal}"/>                                              
                                                <Setter Property="Format" Value="######.#####"/>
                                                <Setter Property="ToolTip" Value="Default value for this commodity"/>
                                            </Style.Setters>
                                        </Style>
                                    </DataPresenter:FieldSettings.EditorStyle>
                                </DataPresenter:FieldSettings>
                            </DataPresenter:Field.Settings>
                        </DataPresenter:Field>
                    </DataPresenter:FieldLayout.Fields>
                </DataPresenter:FieldLayout>
            </DataPresenter:XamDataGrid.FieldLayouts>
        </DataPresenter:XamDataGrid>

Here is the DTO I'm Binding to:

namespace InfragisticsSample
{
    public enum CommodityIdentifier {Electricity, Gas}

    public class MyDTO
    {
        public CommodityIdentifier Commodity { get; set; }
        public double Volume { get; set; }

        public MyDTO(CommodityIdentifier commodity, double volume)
        {
            Commodity = commodity;
            Volume = volume;
        }
    }
}

 

 

Parents
No Data
Reply
  • 4475
    posted

    Hello,

     

    It’s been a while since you have last posted and in case you still need a solution you can use a Mask in order to hide the undesired “$” character and implement a custom formatting in edit and nonedit mode as well.

    The difference between your approach and the above suggested one is that when the editor enters edit mode, it will remove your formatting, so the format property would not work in edit mode.

     

    In the following example I have used mask that displays 5 digits in the integers and 5 digits in the fraction portions part of a grids field:

     

               <igDP:Field Name="Cost" >

                                <igDP:Field.Settings>

                                    <igDP:FieldSettings

                              EditAsType="{x:Type sys:Decimal}">

                                        <igDP:FieldSettings.EditorStyle>

                                            <Style

                                            TargetType="{x:Type igEditors:XamNumericEditor}" >

                                                <Setter Property="Mask" Value="{}{double:5.5}"/>

                                            </Style>

                                        </igDP:FieldSettings.EditorStyle>

                                    </igDP:FieldSettings>

                                </igDP:Field.Settings>

                            </igDP:Field>

     

     

    If you what to upgrade this approach and add some more complicated formatting logic, you can take a look at the following links:

    http://help.infragistics.com/NetAdvantage/WPF/2011.2/CLR4.0/?page=xamEditors_Masks.html

     

    http://help.infragistics.com/NetAdvantage/WPF/2011.2/CLR4.0/?page=InfragisticsWPF4.Editors.v11.2~Infragistics.Windows.Editors.ValueEditor~ValueToTextConverter.html

     

    and

     

    http://help.infragistics.com/NetAdvantage/WPF/2011.2/CLR4.0/?page=InfragisticsWPF4.Editors.v11.2~Infragistics.Windows.Editors.TextEditorBase~ValueToDisplayTextConverter.html

     

    Please do not hesitate to contact us if you have any other questions.

     

    Sincerely,

    Ekaterina

    Developer Support Engineer

    Infragistics Inc.

    www.infragistics.com/support

     

     

Children
No Data