Search code examples
devexpressdevexpress-windows-uidevexpress-wpf

Mask format conditioned


Using the next code:

<dxe:SpinEdit Name="Spin1" IsEnabled="{Binding Data.IsEnabled}" Mask="###.######" MaskType="Numeric"/>

I would like to select the mask format in base of a random value. Kind of(pseudocode):

if (value1 == 1)
{
   Mask="###.######"
}
else
{
   Mask="###.##"
}

I am working in this idea (It is defined in the own grid):

<dxg:FormatCondition Expression="[value1] = '1'" FieldName="Spin1">
     <dxg:Format />
</dxg:FormatCondition>

But how I define the mask in a FormatCondition for an specific case? I Can´t figure out...


Solution

  • Well, I got it by my own...

    Just sharing for if someone need it...

    My idea finally was to send a param from ViewModel which define mask in spin edit.

    <dxg:GridColumn FieldName="value1" AllowEditing="True" Width="80">
                        <dxg:GridColumn.CellTemplate>
                            <DataTemplate>
                                <Border Background="#FFFF99">
                                    <dxe:SpinEdit Name="SpinEditValue1" Mask="{Binding Data.Value1Mask}" MaskType="Numeric" MaskUseAsDisplayFormat="True"/>
                                </Border>
                            </DataTemplate>
                        </dxg:GridColumn.CellTemplate> 
    
            public string Value1Mask
            {
                get 
                {
                    if (Designation == 1)
                    {
                        return "###.##%";
                    }
                    else
                    {
                        return "###.######";
                    }
                }
            }