【发布时间】:2015-06-15 15:25:16
【问题描述】:
我是 xaml 的新手。条目被添加到滚动视图中并随着事件的变化而变化。有许多条目被记录导致内存消耗。如何删除之前输入的条目。那些删除的条目也不应该出现在滚动视图中。提前致谢。
这里是 xaml
<local:ScrollingLV x:Name="LogView" Width="300" Height="100" Margin="10,0,10,10" ItemsSource="{Binding LogMsg}">
这是添加到滚动视图的代码
public partial class ScrollingLV : ListView
{
protected override void OnItemsChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
if (e.NewItems != null)
{
int iCount = e.NewItems.Count;
if (iCount > 0)
{
this.ScrollIntoView(e.NewItems[iCount - 1]);
}
}
base.OnItemsChanged(e);
}
}
【问题讨论】:
-
如何删除ListView中的条目。我已使用此代码删除,但它不起作用。使用 NotifyCollectionsChangedEventArgs。 e.OldItems.Clear()