Issue
Is there a way to force entry to uppercase and How can I uppercase the items inside the picker? If possible without using plugins
Solution
For the Entry, you can change the text to uppercase in TextChanged event.
For the Picker, you usually control the ItemsSource, you just need to uppercase every string in the ItemsSource.
public MainPage()
{
InitializeComponent();
IList<Item> dummyData= new List<Item>
{
new Item { Id = 0, Name = "Item 0" },
new Item { Id = 1, Name = "Item 1" },
new Item { Id = 2, Name = "Item 2" },
};
picker.ItemsSource = dummyData
.Select(i => i.Name.ToUpperInvariant())
.ToList();
entry.TextChanged += OnTextChanged;
}
private void OnTextChanged(object sender, TextChangedEventArgs e)
{
(sender as Entry).Text = e.NewTextValue.ToUpperInvariant();
}
If you're using MVVM, you can use a custom converter for Entry.Text and Picker.ItemsSource binding to change the value to uppercase.
Answered By - Roger Leblanc
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.