Problem with this binding...
-
I have a style defined for a ListViewItem. In this style, there is a MultiDataTrigger. One of the conditions uses RelativeSource to get to a property in the ListView (RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListView}). The trigger is working correctly, just as I expect, so I know all the syntax and everything is defined correctly. HOWEVER, when you scroll a ListView and the ListViewItem goes off screen, it gets removed from the visual tree. This results in a lot of errors: System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='ListView', AncestorLevel='1''. BindingExpression:Path=SomeDP; DataItem=null; target element is 'ListViewItem' (Name=''); target property is 'NoTarget' (type 'Object') I've tried everything I know of to get rid of them: 1) Tried adding a FallbackValue to the binding. This solves the error messages on XP, but does not work on Windows 7??? .NET 4.0 on both OSes. 2) Tried running the value through a dummy converter. This has gotten rid of error messages in the past, but not this time. 3) Tried setting the PresentationTraceSources.TraceLevel="None" AP on the condition. No effect. Any other way to solve this?
-
I have a style defined for a ListViewItem. In this style, there is a MultiDataTrigger. One of the conditions uses RelativeSource to get to a property in the ListView (RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListView}). The trigger is working correctly, just as I expect, so I know all the syntax and everything is defined correctly. HOWEVER, when you scroll a ListView and the ListViewItem goes off screen, it gets removed from the visual tree. This results in a lot of errors: System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='ListView', AncestorLevel='1''. BindingExpression:Path=SomeDP; DataItem=null; target element is 'ListViewItem' (Name=''); target property is 'NoTarget' (type 'Object') I've tried everything I know of to get rid of them: 1) Tried adding a FallbackValue to the binding. This solves the error messages on XP, but does not work on Windows 7??? .NET 4.0 on both OSes. 2) Tried running the value through a dummy converter. This has gotten rid of error messages in the past, but not this time. 3) Tried setting the PresentationTraceSources.TraceLevel="None" AP on the condition. No effect. Any other way to solve this?
I believe that a ListView uses a VirtualizingStackPanel for it's ItemsPanel and that the IsVirtualizing property defaults to true. Try setting it to false if you don't need your listview to hold many items. Either that or try using a regular StackPanel for the ItemsPanel.
while (e) { Coyote(); }
-
I believe that a ListView uses a VirtualizingStackPanel for it's ItemsPanel and that the IsVirtualizing property defaults to true. Try setting it to false if you don't need your listview to hold many items. Either that or try using a regular StackPanel for the ItemsPanel.
while (e) { Coyote(); }
Definitely don't want to turn off virtualization. That eats a lot of memory. If I have 200 items, it adds around 50MB.