我有2個列表。樞軸控件中的樞軸標題和樞軸項目的另一個列表。我無法如此綁定使用樞軸
下面是一個.cs部分。
public class ViewModel
{
List<Feed> feeds = new List<Feed>();
public ViewModel()
{
GetArticlesListingData();
}
public List<Feed> Feeds { get { return this.feeds; } }
private async Task GetArticlesListingData()
{
try
{
for (var k = 0; k < 6; k++)
{
Feed feed1 = new Feed();
feed1.Title = "National" + k;
HttpRequestMessage request1 = new HttpRequestMessage(HttpMethod.Get, "FEEDURL");
request1.Headers.Add("UserAgent", "Windows 8 app client");
request1.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
request1.Headers.Add("Authorization", "bearer " + accessToken);
HttpClient client1 = new HttpClient();
HttpResponseMessage response1 = await client1.SendAsync(request1, HttpCompletionOption.ResponseHeadersRead);
var result1 = await response1.Content.ReadAsStringAsync();
result1 = Regex.Replace(result1, "<[^>]+>", string.Empty);
var rootObject1 = JArray.Parse(result1);
int mainitemsCount = rootObject1.Count();
List<Article> articleList = new List<Article>();
for (int i = 0; i < mainitemsCount; i++)
{
string strHeadline = rootObject1[i]["HeadLine"].ToString();
articleList.Add(new Article
{
Title = rootObject1[i]["Abstract"].ToString(),
HeadLine = rootObject1[i]["HeadLine"].ToString()
});
}
feed1.Articles = articleList;
feeds.Add(feed1);
}
}
catch (Exception ex)
{
}
}
}
public class Feed
{
public string Title { get; set; }
public List<Article> Articles { get; set; }
}
public class Article
{
public string Title { get; set; }
public string HeadLine { get; set; }
}
下面是我的XAML部分,
<Page.Resources>
<local:ViewModel x:Key="ViewModel" />
<DataTemplate x:Key="headerTemplate">
<TextBlock Text="{Binding Title}" />
</DataTemplate>
<DataTemplate x:Key="pivotTemplate">
<ListView Name="ListBox" ItemsSource="{Binding Articles}">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Title}" />
<TextBlock Text="{Binding HeadLine}"/>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</DataTemplate>
</Page.Resources>
<Pivot DataContext="{StaticResource ViewModel}" x:Name="pivot" HeaderTemplate="{StaticResource headerTemplate}" ItemTemplate="{StaticResource pivotTemplate}" ItemsSource="{Binding Feeds}" ></Pivot>
請指引我來解決這個問題。我想綁定數據如下圖像中的支點風格
你能告訴我們的XAML? – bit