Binding in Layout Files with Xamarin.Android

Nathan Sokalski 4,126 Reputation points
2021-03-12T03:31:28.72+00:00

I am coming from a long history of UWP/XAML and a small history of Xamarin.Forms, and am working on converting my apps to Xamarin.Android. One of the things I am yet to learn is the Xamarin.Android equivalent of binding in the layout (*.xml) files. In XAML, this was usually done using code such as {Binding ...} in the XAML file. However, based on what I can find, this is not possible in Xamarin.Android. I always considered binding in the XAML files to be one of the most useful and important features to know. Does Xamarin.Android have a similar feature, or do I need to do all of it using codebehind? Doing it all in codebehind would not only require a hugely larger amount of code, but it would make it much easier to forget things and/or make mistakes, much harder to reuse code, and break the philosophy of separation of UI & logic. Does binding, or a similar feature, exist for Xamarin.Android? Thanks.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,335 questions
0 comments No comments
{count} votes

Accepted answer
  1. JarvanZhang 23,951 Reputation points
    2021-03-12T08:40:59.683+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    Android native provides the Data Binding Library which is actually part of the gradle build toolkit, it isn't available in Xamarin.Android applications. For this function, you could report a feature request to the product team on github.

    Best Regards,

    Jarvan Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.