0
我的Xaml中有一個列表視圖,它綁定到我的數據模型中的ActiveList
屬性。列表視圖在更改集合時未刷新
根據選擇什麼,我想將列表的內容更改爲另一個列表。如果我通過視圖模型進行調試,我可以看到列表正在被分配新列表,但這並未反映在UI中!
這些列表是實現INotifyCollectionChanged接口的ObservableCollections。那麼爲什麼不刷新UI?
視圖模型:
public TcgType SelectedTcgType
{
get { return _selectedTcgType; }
set
{
Set(ref _selectedTcgType, value);
switch (value.Name)
{
case "Yugioh":
ActiveCards = YugiohCards;
break;
case "Hearthstone":
ActiveCards = HearthStoneCards;
break;
case "DBZ":
ActiveCards = DbzCards;
break;
case "Pokemon":
ActiveCards = PokemonCards;
break;
}
//Set(ref _selectedTcgType, value);
}
}
設定功能:基於我Set
方法
public bool Set<T>(ref T field, T value,
[CallerMemberName] string propertyName = null)
{
if (EqualityComparer<T>.Default.Equals(field, value))
return false;
field = value;
RaisepropertyChanged(propertyName);
return true;
}
也許你需要[ObservableCollectionEx(http://stackoverflow.com/questions/269073/observablecollection-that-also-monitors-changes-on-the-elements-in-collection) –