Reputation: 6868
I have created a new class (derived from listview).
This listview is part of a view, which has a viewmodel. This viewmodel has two main properties - 1)myView(ICollectionView)...and isWritable(bool).
Each listview item (row inside listview) has a control template which displays a set of controls.
The visibility of few of these controls is decided by "isWritable" property...thru FindAncestor method.
The ISSUE is..when we scroll this listview, some of the controls which uses "isWritable" property to enable/disable is disabled even though property has value as "True".
If I remove recycling, it works fine...I think this issue is - as it reuses old container..the binding is not happeneing with FindAncestor perfectly.
As u can see, I am using virtualization here..and item panels are recycled. So I think as we reuse the itempanel the databinding is not happening as expected using FindAncestor.
Any help would be appreciated!
<controls:ListViewMine
ItemsSource="{Binding Path=myView}"
VirtualizingStackPanel.IsVirtualizing="true"
ScrollViewer.IsDeferredScrollingEnabled="True"
VirtualizingStackPanel.VirtualizationMode="Recycling"
IsSynchronizedWithCurrentItem="True"
SelectionMode="Single"
Template="{StaticResource myView2}"
AllowDrop="{Binding Path=isWritable}">
<controls:ListViewMine.View>
<controls:GridViewMine ScrollViewer.VerticalScrollBarVisibility="Visible" ColumnHeaderContainerStyle="{StaticResource listViewHeaderStyle}">
<GridViewColumn Width="110" />
<GridViewColumn Header="Name" CellTemplate="{StaticResource templateName}"/>
</controls:GridViewMine>
</controls:ListViewMine.View>
</controls:ListViewMine>
Upvotes: 3
Views: 1739
Reputation: 11
Try VirtualizationMode="Standard"
.
Worked for the problem I had: a celltemplate with a combobox and a selectedindex set. It was not rendering the selected index when scrolling.
I don't know if you will get same improvement with your perf though.
Upvotes: 1