Exemplo n.º 1
0
        public static void UpdateMaxLength(this AutoSuggestBox platformControl, ISearchBar searchBar)
        {
            var maxLength = searchBar.MaxLength;

            if (maxLength == -1)
            {
                maxLength = int.MaxValue;
            }

            if (maxLength == 0)
            {
                MauiAutoSuggestBox.SetIsReadOnly(platformControl, true);
            }
            else
            {
                MauiAutoSuggestBox.SetIsReadOnly(platformControl, searchBar.IsReadOnly);
            }

            var currentControlText = platformControl.Text;

            if (currentControlText.Length > maxLength)
            {
                platformControl.Text = currentControlText.Substring(0, maxLength);
            }
        }
Exemplo n.º 2
0
 public static void UpdateIsReadOnly(this AutoSuggestBox platformControl, ISearchBar searchBar)
 {
     MauiAutoSuggestBox.SetIsReadOnly(platformControl, searchBar.IsReadOnly);
 }