我从Bing API获取搜索结果,并将每篇文章添加到List并尝试将其绑定到XAML中的ListView,但HubSection中没有显示任何结果。
private List<NewsArticle> bNews = new List<NewsArticle>();
其中NewsArticle定义为:
public class NewsArticle : INotifyPropertyChanged
{
private string Description;
public event PropertyChangedEventHandler PropertyChanged;
public string Description1
{
get { return Description; }
set { Description = value; }
}
private string Link;
public string Link1
{
get { return Link; }
set { Link = value; }
}
private string Title;
public string Title1
{
get { return Title; }
set { Title = value;
NotifyProperyChanged("Title");
}
}
public void NotifyProperyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
这是XAML显示我的HubSection和我的绑定。
<HubSection DataContext="{Binding bNews}" Name="newsHub" Header="Hello World">
<DataTemplate>
<ListView ItemsSource="{Binding}" Margin="10" Name="ListBoxRss">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Title1}" Tag="{Binding Link1}" TextWrapping="Wrap" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</DataTemplate>
</HubSection>
我已经四处寻找其他示例,甚至能够在全景风格的应用程序中使其正常工作,但却难以让它在HubSection中正常工作。任何见解都会很棒。