Is there a simple way to disable UI virtualization on a ListBox control? I'm attempting to find a control within a ListBox control using the "FindName()" method, but in the case that the control is visibly off of the Web Browser window, it's not finding the control. I'm almost certain the culprit is UI virtualization. As the control is scrolled off the page, it is no longer retrieved successfully via "FindName()".
The second I scroll it back onto the screen, it returns the control successfully.
This is an extension of this question:
Update with coding example
This is the code behind where I attempt to retrieve the control. "DynamicTagFormFields" is the ListBox control.
textField tf = DynamicTagFormFields.FindName(s.KeyValue) as textField;
This returns a valid "textField" object if the actual textField control that I'm attempting to retrieve is viewable on the screen to the end user. However, if I scroll the textField control out of view using the ListBox's vertical scroll bar, then force the process again, the aforementioned code will return null.
This is the XAML of the ListBox:
<ListBox x:Name="DynamicTagFormFields" Margin="0" Style="{StaticResource ListBoxStyle1}" ItemContainerStyle="{StaticResource ListBoxItemStyle4}" d:LayoutOverrides="Height" Grid.Row="2" IsTabStop="False" TabNavigation="Local" ScrollViewer.HorizontalScrollBarVisibility="Disabled"/>
The textField object is dynamically added to the ListBox programmatically with the following code:
DynamicTagFormFields.Items.Add(textFieldControl);