HappyCoding
HappyCoding

Reputation: 661

How may I bind more than one path value to a label's text property?

Working in Visual Studio 2017 with C# on an Xamarin.Forms application, I have the following line within the creation of a ListView. Each item in the ListView is represented by one Label. I set each label's text property to that item's 'Number' value. It is working as when viewing the list while running.

label.SetBinding(Label.TextProperty, "Number");

Along with the 'Number' value, each item in the list has a 'SecondNumber' value. How may I bind the 'Number' value, a hyphen, and the 'SecondNumber' value to the each label's text property?

I've tried the following without success:

label.SetBinding(Label.TextProperty, "Number" + "-" + "SecondNumber");

Upvotes: 0

Views: 94

Answers (1)

Kramb
Kramb

Reputation: 1092

You can add a combined value property to your object. This way, you can use it anywhere in your application.

public string Numbers{
    get {return this.Number + "-" + this.SecondNumber;}
}

Upvotes: 1

Related Questions