我有一個列表視圖,我將從我的數據庫獲得的值綁定到我的XAML。我將一個值綁定到我的XAML中,但是我希望綁定兩個值,這是可能的還是隻能在代碼中使用?如果是這樣,我將如何實現這一目標。無論如何,我可以將兩個值綁定到我的XAML中嗎?
這是我的代碼:
public class items
{
public string infoOne { get; set;}
public string infoTwo { get; set;}
}
async void loadList()
{
var getItems = await phpApi.getEvents();
theList = new List <items>();
foreach (var currentitem in getItems["results"]) {
theList.Add (new items() {
infoOne = currentitem ["name"].ToString(),
infoTwo = currentitem ["phone"].ToString()
});
mylist.ItemsSource = theList;
}
XAML:
<Label Text = "{Binding infoOne}" /> //How could I add infoTwo to the same label and also add a space between them?
我剛剛更新了我的答案,以更好地滿足您的問題 – Matt