问题描述
我有一个页面,其中包含一个带复选框的List,并且每次我检查一个项目从一个AppBar切换到另一个有删除的项目时,它绑定到一个ObservableCollection
按钮,我正在使用collectionChanged事件来触发此切换,我的问题是当我删除一个项目并且缺陷属性现在为false时删除按钮仍然存在,它不会切换回默认的AppBar ..这是我的CollectionChanged事件:
I have a page that has a List with checkboxes and its bound to an ObservableCollection
everytime i check an item it switches from one AppBar to another that has a delete button, i am using a collectionChanged event to trigger this switching, my problem is when i delete an item and the ischecked property is now false the delete button still remains, it doesn't switch back to the default AppBar..here is my CollectionChanged event:
void MyItems_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
if (e.NewItems != null)
{
foreach (MyItems item in e.NewItems)
{
item.PropertyChanged += item_PropertyChanged;
}
}
if (e.OldItems != null)
{
foreach (MyItems item in e.OldItems)
{
item.PropertyChanged -= item_PropertyChanged;
}
}
}
void item_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == "IsChecked")
{
if (MyItems.Any(i => i.IsChecked == true))
{
ApplicationBar = (Microsoft.Phone.Shell.ApplicationBar)Resources["AppBarChecked"];
}
else
{
ApplicationBar = (Microsoft.Phone.Shell.ApplicationBar)Resources["AppBarNotChecked"];
}
}
}
所以任何可能导致问题的想法。
注意:我已经在PhoneApplicationPage Resources中声明了我的AppBars。
so any ideas of what could be causing the problem.
Note: I have declared my AppBars in the PhoneApplicationPage Resources.
推荐答案
CustomMessageBox
导致了错误。如果遇到这样的错误,请确保使用其他工具包,看看它是否解决了问题。
was causing the error. if you encounter such a bug make sure to use another toolkit and see if it solves the problem.
这篇关于同一应用程序页面上的多个应用程序栏无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!