This is a migrated thread and some comments may be shown as answers.

DataFormDataField derivation for RadMaskedNumericInput has problems

2 Answers 63 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 27 Sep 2013, 10:48 PM
Hello,
I derived the DataFormDataField class to return a RadMaskedNumericInput control.  Three problems are readily apparent.

1. The DataMemberBinding does not propagate to the control from the DataFormDataField derivative.
2. The IsReadOnly property is not propagated to the control.
3. The Width property of the DataFormDataField class does not effect the Width of the control.


Here's the code...
/// <summary>
/// Numeric specific <c>DataFormDataField</c>.
/// </summary>
public class DataFormNumericField : DataFormDataField
{
 
    /// <summary>
    /// Returns a control to display and edit the underlying data.
    /// </summary>
    /// <returns><c>Control</c></returns>
    protected override Control GetControl()
    {
        RadMaskedNumericInput ctrl = new RadMaskedNumericInput();
 
        return ctrl;
    }
}

You'll notice below, there is an extension to the DataFormDataField that sets the width of the label portion.  Other than that, it is a standard DataFormDataField derivation.
<amUI:DataFormNumericField x:Name="BatchNumberField"
                           DataMemberBinding="{Binding SelectedBatch.JournalEntryBatchNumber,
                                ValidatesOnDataErrors=True,
                                ValidatesOnExceptions=True,
                                NotifyOnValidationError=True,
                                UpdateSourceTrigger=PropertyChanged}"
                           Label="{x:Static localProperties:Resources.Batch_Number}"
                           Width="163"
                           amUI:DataFormColumn.LabelColumnWidth="80"
                           IsReadOnly="True">
    <amUI:DataFormNumericField.Resources>
        <Style TargetType="telerik:RadMaskedNumericInput">
            <Setter Property="Placeholder"
                    Value=" " />
            <Setter Property="SelectionOnFocus"
                    Value="SelectAll"/>
            <Setter Property="IsClearButtonVisible"
                    Value="False" />
            <Setter Property="AllowSkipPlaceholders"
                    Value="False" />
            <Setter Property="AutoFillNumberGroupSeparators"
                    Value="False" />
            <Setter Property="AutoFillZeros"
                    Value="False" />
            <Setter Property="Mask"
                    Value="#10" />
        </Style>
    </amUI:DataFormNumericField.Resources>
</amUI:DataFormNumericField>

Could you provide an example where these three issues are addressed?

Thanks in advance,
Steve

2 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Ivanov
Telerik team
answered on 02 Oct 2013, 12:09 PM
Hello,

You should handle both IsReadOnly and DataMemberBinding on your side. You can have a look at this article, which illustrates a similar scenario. Can you please throw some light on the last (third) point of your list? I fear that I might have misunderstood you. What is the behavior that you expect?

Regards,
Ivan Ivanov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Steve
Top achievements
Rank 1
answered on 02 Oct 2013, 06:36 PM
The article pointed me in the right direction!
Thanks,
Steve
Tags
DataForm
Asked by
Steve
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Steve
Top achievements
Rank 1
Share this question
or