RadNumericInput style by validator error

1 Answer 51 Views
NumericInput Styling
n/a
Top achievements
Rank 1
Iron
n/a asked on 28 Dec 2022, 09:57 AM

I using styling validation on form by DataTrigger.
When Validator.IsValid == false then DataTrigger changes specified feature.

In case of standard RadEntry control, I could specify BorderColor.

But how to work with RadNumericinput when such control not exposes any input element property?

<telerikInput:RadNumericInput x:Name="numericInput" 
                                          IsEnabled="{Binding IsEnabled}"
                                          Value="{Binding Value,Mode=TwoWay}"
                                          VerticalOptions="Center" 
                                          HorizontalOptions="FillAndExpand">
                <telerikInput:RadNumericInput.Triggers>
                    <DataTrigger TargetType="telerikInput:RadNumericInput"
                                 Binding="{Binding Validator.IsValid}"
                                 Value="False">
                        <Setter Property="BorderStyle">
                            <telerikInput:BorderStyle BorderColor="{DynamicResource ErrorColor}" />
                        </Setter>
                    </DataTrigger>
                </telerikInput:RadNumericInput.Triggers>
            </telerikInput:RadNumericInput>


1 Answer, 1 is accepted

Sort by
0
Didi
Telerik team
answered on 28 Dec 2022, 03:46 PM | edited on 28 Dec 2022, 03:48 PM

Hi Maciej,

There isn't a border style property exposed in the RadNumericInput control.

I can suggest you display a validation error message when the input is not allowed. For example add additional Label next to/above/below the numeric and change its visibility when the input value does not match the requirements. 

for example:

<StackLayout>
    <telerikInput:RadNumericInput x:Name="numericInput"
                            Value="{Binding Data, Mode=TwoWay}"
                            VerticalOptions="Center"
                            HorizontalOptions="FillAndExpand"/>

    <Label Text="wrong input, the value must be between 0 and 10" TextColor="Red" IsVisible="{Binding IsValueValid}"/>
</StackLayout>

 

In addition you can set the minimum and maximum values to restrict the inputs: https://docs.telerik.com/devtools/xamarin/controls/numericinput/numericinput-key-features#restricting-the-input 

Regards,
Didi
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

n/a
Top achievements
Rank 1
Iron
commented on 28 Dec 2022, 03:56 PM

Thank you for answer.
I see that both feature requests are unplanned.

I decided to use Telerok controls and now I discover that I cannot use those because of uncosistncency with styling.
Entry control could be styled, numeric control canot.
I cannot style app in different way on one form.
There should be exposed style property for all child elements in the same way.

Lance | Manager Technical Support
Telerik team
commented on 28 Dec 2022, 04:24 PM

Hi Maciej,

If you are willing to use a ControlTemplate, you can go one level down and work with the internal NumericInputEntry element. See this documentation for how to get a copy of the ControlTemplate => Xamarin NumericInput Documentation | Control Template.

Note, this of course doesn't work the same as what you already have, but I believe you can get pretty close.

Tags
NumericInput Styling
Asked by
n/a
Top achievements
Rank 1
Iron
Answers by
Didi
Telerik team
Share this question
or