Posts

Showing posts with the label control

[Xamarin Forms] Entry with rounded borders in your app

Image
Entry with rounded borders in your app (Xamarin Forms, NET MAUI) I know for some people it will be obvious, but I always seepeople asking how to make a custom Entry control with rounded borders...  To add rounded corners globally to Entry controls in a Xamarin Forms or .NET MAUI application, you can define a Style in the App.xaml (or Styles.xaml for .NET MAUI). This style will automatically apply to all Entry controls in your app, saving you from having to manually style each one. Example Define the global style in App.xaml : <Application.Resources> <ResourceDictionary> <Style TargetType="Entry"> <Setter Property="BackgroundColor" Value="White"/> <Setter Property="TextColor" Value="Black"/> <Setter Property="CornerRadius" Value="10"/> <Setter Property="HeightRequest" Value="50"/>

Xamarin.Forms: Picker control and "Items" binding problem...

Image
If I tell you "ComboBox", you will see quickly of which control I'm talking about. There no control named "ComboBox" in Xamarin.Forms but if you search a little, you will find the "Picker " control. Class: Xamarin.Forms.Picker In the namespace: Xamarin.Forms Doc link : http://iosapi.xamarin.com/index.aspx?link=T%3AXamarin.Forms.Picker The problem is that you cannot bind directly "Picker.Items" property in the XAML file ! For that you have to use the code behind file. xaml (doesn't work): <Picker Items="{Binding MyViewModelList}"... /> So what do we have to do ? 1- Name your "Picker" control in the xaml file (by adding an attribute like x:Name="uiPicker" ) 2- On the parent page in code behind, override the "OnBindingContextChanged( )" method 3- In this method, fill your "Picker.Items" property from your viewmodel's values. 4- On the XAML file, you can onl