@@ -57,12 +57,12 @@ public class SfOtpInput : SfView, IKeyboardListener, IParentThemeElement
57
57
/// <summary>
58
58
/// Width of each OTP input field.
59
59
/// </summary>
60
- float _entryWidth = 40 ;
60
+ float _entryWidth ;
61
61
62
62
/// <summary>
63
63
/// Height of each OTP input field.
64
64
/// </summary>
65
- float _entryHeight = 40 ;
65
+ float _entryHeight ;
66
66
67
67
/// <summary>
68
68
/// Corner radius for the rounded edges of OTP input fields.
@@ -155,6 +155,18 @@ public class SfOtpInput : SfView, IKeyboardListener, IParentThemeElement
155
155
/// </summary>
156
156
bool _isPasteHandled = false ;
157
157
#endif
158
+
159
+ /// <summary>
160
+ /// Identifies the BoxWidth bindable property.
161
+ /// </summary>
162
+ public static readonly BindableProperty BoxWidthProperty =
163
+ BindableProperty . Create ( nameof ( BoxWidth ) , typeof ( double ) , typeof ( SfOtpInput ) , 40.0 , BindingMode . TwoWay , propertyChanged : OnBoxSizePropertyChanged ) ;
164
+
165
+ /// <summary>
166
+ /// Identifies the BoxHeight bindable property.
167
+ /// </summary>
168
+ public static readonly BindableProperty BoxHeightProperty =
169
+ BindableProperty . Create ( nameof ( BoxHeight ) , typeof ( double ) , typeof ( SfOtpInput ) , 40.0 , BindingMode . TwoWay , propertyChanged : OnBoxSizePropertyChanged ) ;
158
170
#endregion
159
171
#region BindableProperties
160
172
@@ -303,6 +315,8 @@ public SfOtpInput()
303
315
{
304
316
ThemeElement . InitializeThemeResources ( this , "SfOtpInputTheme" ) ;
305
317
DrawingOrder = DrawingOrder . BelowContent ;
318
+ _entryWidth = ( float ) BoxWidth ;
319
+ _entryHeight = ( float ) BoxHeight ;
306
320
InitializeFields ( ) ;
307
321
#if IOS
308
322
this . IgnoreSafeArea = true ;
@@ -737,6 +751,24 @@ public Color InputBackground
737
751
{
738
752
get { return ( Color ) GetValue ( InputBackgroundProperty ) ; }
739
753
set { SetValue ( InputBackgroundProperty , value ) ; }
754
+ }
755
+
756
+ /// <summary>
757
+ /// Gets or sets the width of each OTP input box.
758
+ /// </summary>
759
+ public double BoxWidth
760
+ {
761
+ get => ( double ) GetValue ( BoxWidthProperty ) ;
762
+ set => SetValue ( BoxWidthProperty , value ) ;
763
+ }
764
+
765
+ /// <summary>
766
+ /// Gets or sets the height of each OTP input box.
767
+ /// </summary>
768
+ public double BoxHeight
769
+ {
770
+ get => ( double ) GetValue ( BoxHeightProperty ) ;
771
+ set => SetValue ( BoxHeightProperty , value ) ;
740
772
}
741
773
742
774
#endregion
@@ -1121,6 +1153,20 @@ static void OnStrokePropertyChanged(BindableObject bindable, object oldValue, ob
1121
1153
}
1122
1154
}
1123
1155
1156
+ /// <summary>
1157
+ /// Add this property changed handler
1158
+ /// </summary>
1159
+ static void OnBoxSizePropertyChanged ( BindableObject bindable , object oldValue , object newValue )
1160
+ {
1161
+ if ( bindable is SfOtpInput otpInput )
1162
+ {
1163
+ otpInput . _entryWidth = ( float ) otpInput . BoxWidth ;
1164
+ otpInput . _entryHeight = ( float ) otpInput . BoxHeight ;
1165
+ otpInput . InvalidateMeasure ( ) ;
1166
+ otpInput . InvalidateDrawable ( ) ;
1167
+ }
1168
+ }
1169
+
1124
1170
#endregion
1125
1171
1126
1172
#region Public Methods
@@ -1970,7 +2016,7 @@ void DetachEvents(OTPEntry otpEntry)
1970
2016
/// Handles key down events for OTP input fields.
1971
2017
/// </summary>
1972
2018
/// <param name="sender">The object that triggered the event.</param>
1973
- /// <param name ="e">Event arguments containing key information.</param>
2019
+ /// <param { get; set; } ="e">Event arguments containing key information.</param>
1974
2020
void OnKeyDown ( object sender , Microsoft . UI . Xaml . Input . KeyRoutedEventArgs e )
1975
2021
{
1976
2022
if ( _otpEntries is null )
@@ -2257,7 +2303,7 @@ void OnPreviewKeyDown(KeyEventArgs e)
2257
2303
/// Sets up platform-specific event handlers for key input validation and handling.
2258
2304
/// </summary>
2259
2305
/// <param name="sender">The OTPEntry control whose handler has changed.</param>
2260
- /// <param name ="e">Event arguments containing details of the change.</param>
2306
+ /// <param { get; set; } ="e">Event arguments containing details of the change.</param>
2261
2307
void OnHandlerChanged ( object ? sender , EventArgs e )
2262
2308
{
2263
2309
if ( sender is OTPEntry textBox )
0 commit comments