What is Device.BeginInvokeOnMainThread for?

Just to add an example. Imagine you have an async method DoAnyWorkAsync if you call it (just as an example) this way: DoAnyWorkAsync().ContinueWith ((arg) => { StatusLabel.Text = “Async operation completed…”; }); StatusLabel is a label you have in the XAML. The code above will not show the message in the label once the async … Read more

Xamarin Forms Button Command binding inside a ListView

Jan, Since you’ve used a list view and your commands are inside the DataTemplate, the binding is attached to the binding context of the each individual model in the ItemSource. A way around this is do do the following: <ListView Grid.Row=”1″ x:Name=”ArbeitsEinträgeList” ItemsSource=”{Binding EintragList}” SelectedItem=”{Binding SelectedItem}”> <ListView.ItemTemplate> <DataTemplate> <ViewCell> <ViewCell.View> <Grid x:Name=”Item”> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition/> … Read more

What is MAUI? and what are differences between MAUI and Xamarin

With .NET 5 Microsoft begins the journey of unifying the .NET platform, bringing .NET Core and Mono/Xamarin together in one base class library (BCL) and toolchain (SDK), more about it here. .NET MAUI is a name for a new upgraded solution as a Multi-platform App UI framework for building native cross-platform apps with .NET for … Read more

Horizontal ListView Xamarin.Forms

As of Xamarin Forms 2.3 CarouselView does just that, and more. Read more here. <ContentView HorizontalOptions=”FillAndExpand” VerticalOptions=”FillAndExpand”> <CarouselView ItemsSource=”{Binding MyDataSource}”> <CarouselView.ItemTemplate> <DataTemplate> <Label Text=”{Binding LabelText}” /> </DataTemplate> </CarouselView.ItemTemplate> </CarouselView> </ContentView>

How to run a method in the background only when app is open and running?

What we did in our forms application was to make use of the Device.Timer and the Stopwatch class that available in System.Diagnostics, and Xamarin.Forms to create a very generic managed timer that we could interact with using the onStart, onSleep and onResume methods in Xamarin.Forms. This particular solution doesn’t require any special platform specific logic, … Read more

How to store App settings in Xamarin.Forms

It can be done this way too using Properties Dictionary for storing data: Application.Current.Properties [“id”] = someClass.ID; for fetching data: if (Application.Current.Properties.ContainsKey(“id”)) { var id = Application.Current.Properties [“id”] as int; // do something with id } ref: https://developer.xamarin.com/guides/xamarin-forms/working-with/application-class/#Properties_Dictionary