MaskedEntry control - entered value will not bind to my model property

1 Answer 38 Views
MaskedEntry
Mike
Top achievements
Rank 1
Mike asked on 26 May 2024, 02:27 AM

Using the RadRegexMaskedEntry below but I cannot get the value to bind to my model.  Unless I'm wrong, the documentation suggests Value is the right attribute to use but it never binds when a value is entered.   I know my model is correct because  I have about 6 other controls on this page (mostly RadComboBox and RadEntry) including the 'Registered for GST' RadCheckBox and they all bind correctly. 

<Grid Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="2" RowDefinitions="Auto,Auto" ColumnDefinitions="Auto,Auto"  >
    <Label Grid.Row="0" Text="Insured ABN" Margin="10,10,0,0" FontAttributes="Bold" TextColor="{DynamicResource RA_DarkBlue}"
            VerticalTextAlignment="Center" HorizontalOptions="Start" />
    <telerik:RadRegexMaskedEntry Grid.Row="1" x:Name="txtABN" Value="{Binding CurrentApplication.Abn}"
                                 Mask="^\s*[1-9](\s*\d){10}\s*$" WidthRequest="200" Margin="10,5,0,5" 
                                 ValidationErrorMessage="Invalid ABN" 
                                 BackgroundColor="White" VerticalOptions="End" />

    <Label Grid.Row="0" Grid.Column="1" Text="Registered for GST" Margin="20,10,0,0" FontAttributes="Bold" TextColor="{DynamicResource RA_DarkBlue}"
            VerticalTextAlignment="Center"  />
    <telerik:RadCheckBox Grid.Row="1" Grid.Column="1" x:Name="chkRegisteredForGST" IsChecked="{Binding CurrentApplication.RegisteredForGST}"
                            WidthRequest="40" HorizontalOptions="Start"
                            VerticalOptions="Center" BackgroundColor="AliceBlue" Margin="10,0,10,10" />
</Grid>

Just for reference, I'm using the Maui Community MVVM Toolkit and the two properties in the XAML below look like this in my model.  The instance of this model is a singleton in my VM and named "CurrentApplication' (hence XAML reference).  

    public partial class ApplicationData : ObservableObject
    {
        //...other observable proerties...

        [ObservableProperty]
        private string? abn;

        [ObservableProperty]
        private bool registeredForGST;

       //...etc...
}
So I don't know why it won't bind when everything else on the page binds without any issue.  I'm sure I'm just doing something silly but no amount of messing with it seems to solve it, can someone advise please?

1 Answer, 1 is accepted

Sort by
0
Didi
Telerik team
answered on 27 May 2024, 10:16 AM

Hi Mike,

Set the binding mode to two way: 

        <telerik:RadRegexMaskedEntry Grid.Row="1" x:Name="txtABN" Value="{Binding CurrentApplication.Abn, Mode=TwoWay}"
                                 Mask="^\s*[1-9](\s*\d){10}\s*$" WidthRequest="200" Margin="10,5,0,5" 
                                 ValidationErrorMessage="Invalid ABN" 
                                 BackgroundColor="White" VerticalOptions="End" />

For RadCheckBox.IsChecked property the default mode is two way. 

If this does not help, then send me a sample project where the behavior occurs. If you do not want to share the project in the forum, you can open a support ticket.

Regards,
Didi
Progress Telerik

A brand new ThemeBuilder course was just added to the Virtual Classroom. The training course was designed to help you get started with ThemeBuilder for styling Telerik and Kendo UI components for your applications. You can check it out at https://learn.telerik.com
Mike
Top achievements
Rank 1
commented on 29 May 2024, 05:01 AM

Thanks Didi, that seems to have fixed the issue.  Seems a bit inconsistent having one rule for that control that is different for other controls but at least now I know.
Tags
MaskedEntry
Asked by
Mike
Top achievements
Rank 1
Answers by
Didi
Telerik team
Share this question
or