Windows phone 7 我的数据绑定失败,路径是否错误?
我正在尝试创建一个简单的RSS新闻聚合器。但我的装订有问题 xaml:Windows phone 7 我的数据绑定失败,路径是否错误?,windows-phone-7,data-binding,mvvm,Windows Phone 7,Data Binding,Mvvm,我正在尝试创建一个简单的RSS新闻聚合器。但我的装订有问题 xaml: <phone:LongListSelector x:Name="MainLongListSelector" Margin="0,0,-12,0" ItemsSource="{Binding Path=News.List}" SelectionChanged="MainLongListSelector_SelectionChanged"> N
<phone:LongListSelector
x:Name="MainLongListSelector"
Margin="0,0,-12,0"
ItemsSource="{Binding Path=News.List}"
SelectionChanged="MainLongListSelector_SelectionChanged">
NewsRepository
只是一个持有列表的模型对象。有人能给我指一下东西横着的方向吗
该应用程序运行正常,但我手动输入的列表中的单个项目没有显示在应用程序中:-(
我已经在将DataContext
分配给viewmodels内容的位置设置了断点
NewsViewModel
和NewsRepository
都必须实现INotifyPropertyChanged
如果您使用ObservableCollection
作为绑定源,而不是自定义NewsRepository
对象,则会更容易
如果没有更多的代码,很难说。显示您的longlistselector项模板、News.List和News.List对象中的对象定义。同意@AlaaMasoud,您可以发布更多代码吗。App.ViewModel是NewsViewModel的实例吗?NewsRepository是否有List属性?
(mainpage)
public MainPage()
{
InitializeComponent();
// Set the data context of the LongListSelector control
// to the sample data
DataContext = App.ViewModel;
(viewmodel)
public class NewsViewModel : BaseViewModel
{
public NewsRepository News { get; private set; }
}