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
325
When the EditorStyle of the NumericField is changed to Mask, the val becomes null in the SetDataValueHelper method.
posted

var field = new NumericField()
{
    Width                        = FieldLength.Auto,
    Name                         = $"RefData{no}",
    Label                        = $"{item.Name} ({item.Unit})",
    DataType                     = typeof(double),
    AllowEdit                    = true, 
    Format                       = Datas.RefFormat,
    EditorStyle                  = m_view.TryFindResource("Stype_NumericMaskedEditor") as Style,
    HorizontalContentAlignment   = System.Windows.HorizontalAlignment.Right
};

this.m_view.U_FieldLayout.Fields.Add(field);

<Style x:Key="Stype_NumericMaskedEditor" TargetType="{x:Type igEditors:XamNumericEditor}">
    <Setter Property="Mask" Value="{}{double:4.10}" />
    <Setter Property="InvalidValueBehavior" Value="RevertValue" />
    <Setter Property="AcceptsArrowKeysInEditMode" Value="False" />
    <Setter Property="ValueConstraint">
        <Setter.Value>
            <igEditors:ValueConstraint MaxInclusive="9999.99"
                                       MinInclusive="0"
                                       Nullable="False" />
        </Setter.Value>
    </Setter>
</Style>

 private string _RefData1 = "0";
 public string RefData1
 {
     get { return _RefData1; }
     set
     {
         _RefData1 = value;
         OnPropertyChanged("RefData1");
     }
 }

If I set the initial value of RefData1 to "0", it will be displayed as the initial value when the unbound field is added. However, I want the field to remain blank until a value is entered.

When I set RefData1 to an empty string (""), val becomes null in the SetDataValueHelper method. While this behavior is expected, how can I achieve my desired behavior?