Silverlight的Windows Phone的数据绑定 - noob问题

我有一个基本的Windows Phone应用程序列表,用code这样的MainViewModel类

I have a basic Windows Phone List application, with code like this in the MainViewModel class

// CODE THAT WORKS --

Items.Clear();

foreach (var itm in e.Result)
    Items.Add(itm);

Count = Items.Count;

// CODE THAT DOES NOT WORK -- I'm trying to understand WHY

Items = e.Result;

数据绑定的XAML看起来是这样的:

The databinding Xaml looks like this:

<DataTemplate>
    <StackPanel x:Name="DataTemplateStackPanel" Orientation="Horizontal">
        <Image x:Name="ItemImage" Source="/AppName;component/Images/ArrowImg.png" Height="43" Width="43" VerticalAlignment="Top" Margin="10,0,20,0"/>
        <StackPanel>
            <TextBlock x:Name="ItemText" Text="Event Name" Margin="-2,-13,0,0" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
            <TextBlock x:Name="DetailsText" Text="{Binding Path=Description}" Margin="0,-6,0,3" Style="{StaticResource PhoneTextSubtleStyle}"/>
        </StackPanel>
    </StackPanel>
</DataTemplate>

我想我的ObservableCollection和INotifyPropertyChanged的是如何工作的误解,因为我认为这code应该工作。数据绑定到NonCollection项目正在按我期待着与我的INotifyPropertyChanged的实施。

I think I have a misunderstanding of how ObservableCollection and INotifyPropertyChanged work, because I'm thinking that this code should work. Databinding to NonCollection items is working as I'd expect with my INotifyPropertyChanged implementation.



 1 条回答