摘要:
部落格分類:
FAQ
問題:WPF中MVVM模式下 ListView繫結ListCollectionView時,CurrentChanged無法觸發
解決方案:
初期方案:利用ListView的Selec...
部落格分類:
ofollow,noindex" target="_blank">FAQ
- 問題:WPF中MVVM模式下 ListView繫結ListCollectionView時,CurrentChanged無法觸發
-
解決方案:
- 初期方案:利用ListView的SelectionChanged事件在介面後臺邏輯中呼叫VM業務邏輯。 —— 弊端:前後耦合度增加。
- 最終方案:設定ListView的IsSynchronizedWithCurrentItem屬性為True。
-
經歷(吐槽):
- 百度看了幾頁沒找到解決方案,谷歌第一頁就找到了。 —— 真不是我崇洋媚外,我也很無奈。
- 搜尋詞:“WPF ListView ListCollectionView CurrentChanged” —— 供驗證,偶木有騙人。
解:奇葩史