Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

How to pass a binding from Xaml to a public variable?

$
0
0

I have a ContentPage class (Let's call it ClassOne) that contains a public variable:

public string Title { get; set; }
public ClassOne() //Constructor
{
   this.InitializeComponent();
   BindingContext = this;
}

And its Xaml file has a label which takes info from the Title:
<Label Text="{Binding Title}" TextColor="Red" />

It works if I set the Title property within the class, but I'm trying to pass it from another class that contains this Xaml:
<local:ClassOne Title="example"/>
But it shows an empty label..
How can I pass the string as a xaml property to ClassOne's 'Title' string?


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>