我有一个平板电脑应用程序(Windows 8应用程序),带有一个起始主页。我将ListView绑定到ObservableCollection,并将UpdateSourceTrigger设置为PropertyChanged ...在此列表中我动态创建Panels(使用删除按钮)。当我创建按钮然后我单击删除按钮一切正常..面板消失了很好的动画。但是,当我创建一个新面板..然后我导航到另一个页面并返回主页,单击删除任何这些面板,他们不会消失..但如果再次导航到另一个页面然后我回去。面板被删除。我试着调试那个集合,一切看起来都很好。试图将UpdateSourceTrigger更改为Explicit并手动调用它但没有成功。谢谢你的帮助
HomePage.xaml中的ListView Xaml
<ListView x:Name="CListView" Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="40, 0, 50, 50"
SelectionMode="None" IsItemClickEnabled="True" ItemClick="CListView_OnItemClick"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
ScrollViewer.HorizontalScrollMode="Auto"
ScrollViewer.VerticalScrollMode="Disabled"
ScrollViewer.ZoomMode="Disabled"
ScrollViewer.IsHorizontalScrollChainingEnabled="True"
ItemsSource="{Binding Path=ClControls, ElementName=HomePageElementName, UpdateSourceTrigger=PropertyChanged}">
<ListView.ItemContainerStyle>
HomePage.xaml.cs OnItemRemove
public ObservableCollection<IClControl> ClControls
{
get { return _clEvents; }
set
{
_clEvents = value;
OnPropertyChanged();
}
}
private async void ClControl_OnItemRemove(object sender, ClControlRemoveItemArgs e)
{
var control = sender as ClControl;
if (control == null)
return;
var clEvent = e.ClEventInfo;
// control.OnItemRemove -= ClControl_OnItemRemove;
if (ClControls.Contains(control))
{
ClControls.Remove(control);
}
if (SessionHolder.Instance.ClControls.Contains(control))
{
SessionHolder.Instance.ClControls.Remove(control);
}
await clEvent.Delete();
}