私はObservableCollectionをカスタムリストボックスで表示しています。 i注意ObservableCollectionがリストビューを更新しない
<ListBox x:Name="listBox1" >
<ListBox.ItemTemplate >
<DataTemplate >
<StackPanel Width="400" Margin="20" >
<Button x:Name="pic" Tag="{Binding Id}">
<Button.Template>
<ControlTemplate>
<TextBlock Text="{Binding title}" TextWrapping="Wrap" FontFamily="Arial" FontSize="28" Tag="{Binding Id}"/>
</ControlTemplate>
</Button.Template>
</Button>
<TextBlock Text="{Binding pudate}" TextWrapping="Wrap" FontSize="24"/>
<Image Source="{Binding source_icon}" Width="100" Height="60"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
XAML
public class lbl
{
public ObservableCollection<feed> ModifiedItems
= new ObservableCollection<feed>();
public lbl()
{
InitializeComponent();
listBox1.ItemsSource = ModifiedItems ;
}
public void update(object sender, EventArgs e)
{
var x = ModifiedItems.Last();
listBox1.Items.Add(x);
}
}
public class feed
{
public int ID { get; set; }
public int source_id { get; set; }
public string title { get; set; }
public string source_icon { get; set; }
public string url { get; set; }
public string pudate { get; set; }
}
の下に入手可能である新しいフィードを挿入するかのObservableCollectionからコードの
部品をフィードを除去するように、適用された変更に応じてビューを更新するリストボックスが必要です。これはコードの一部ではありません。 「読み取り専用コレクションでサポートされていない操作」アイテムを追加しようとすると、エラーが表示されます。
ここに投稿されたソリューションを試しましたが、Implementing CollectionChangedと同じエラーが表示されます。
すべてのヘルプしてください、事前