Silverlight:禁用UI虚拟化? [英] Silverlight: Disable UI virtualization?

查看:51
本文介绍了Silverlight:禁用UI虚拟化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种简单的方法来禁用ListBox控件上的UI虚拟化?我试图使用"FindName()"方法在ListBox控件中找到一个控件,但是在该控件明显位于"Web浏览器"窗口之外的情况下,找不到该控件.我几乎可以确定罪魁祸首是UI虚拟化.当控件滚动到页面之外时,不再可以通过"FindName()"成功检索到它.

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.

这是此问题的扩展:

Silverlight:FrameworkElement.FindName()当控件不可见"时,找不到控件在浏览器窗口中

使用编码示例进行更新

这是我尝试检索控件背后的代码."DynamicTagFormFields"是ListBox控件.

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;

如果最终用户在屏幕上可以看到我尝试检索的实际textField控件,则此方法将返回有效的"textField"对象.但是,如果我使用ListBox的垂直滚动条将textField控件滚动到视图之外,然后再次强制执行该过程,则上述代码将返回null.

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.

这是ListBox的XAML:

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"/>

textField对象通过以下代码以编程方式动态添加到ListBox中:

The textField object is dynamically added to the ListBox programmatically with the following code:

DynamicTagFormFields.Items.Add(textFieldControl);

推荐答案

您是否尝试过:-

<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">
    <ListBox.ItemsPanel>
       <ItemsPanelTemplate>
           <StackPanel />
       </ItemsPanelTemplate>
    </ListBox.ItemsPanel>
</ListBox>

默认面板是 VirtualisingStackPanel ,这可能是导致问题的原因.

The default panel is the VirtualisingStackPanel which may be the cause of your problem.

这篇关于Silverlight:禁用UI虚拟化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆