WPF MVVM: how to bind GridViewColumn to ViewModel-Collection?

前端 未结 3 1364
独厮守ぢ
独厮守ぢ 2020-12-01 02:16

In my View I got a ListView bound to a CollectionView in my ViewModel, for example like this:



        
3条回答
  •  眼角桃花
    2020-12-01 02:53

    I think this code would cause some memory leak issues; As your class GridViewColumns described, you've defined a static dictionary "_gridViewsByColumnsSource" in which contains the gridviews and their columns source references; so this is a strong reference to the added gridviews and columns source; Because this dictionary is static, it seems that there's a static reference "point" to the gridviews and columns source data all the time, if the screen in which the gridview defined closed, the gridview cannot be collected by GC if GC is started; As more and more similar screens opened, more and more gridviews and its columns source data cannot be collected, there'll be memory leak at the end.

提交回复
热议问题