如何以最高效率实现这个问题? [英] How to achieve this problem with the highest efficiency?

查看:77
本文介绍了如何以最高效率实现这个问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如图所示,每五个radiobutton被放置在一个堆叠面板中。单击radiobutton时,raduibutton上的数字将存储在数据库中。如果有
数千个radiobuttons,我怎么能快速完成?

As shown in the figure, every five radiobuttons are placed in a stackpanel. When a radiobutton is clicked, the number on the raduibutton is stored in the database. If there are Thousands of radiobuttons, how can I do this quickly?

推荐答案

嗨    iDontKnowEverything, 



>>如果有成千上万的radiobuttons,我怎么能快速做到这一点



据我所知,当你有成千上万的面板中的radiobuttons。主要问题是UI的延迟和缓慢,影响操作和体验。



因此,我建议您可以尝试在WPF中使用UI虚拟化,其次是数据虚拟化。 UI虚拟化最大限度地减少了绘制的内容,数据虚拟化最大限度地减少了可以绘制的内容。



一个简单的示例:

Hi   iDontKnowEverything, 

>> If there are Thousands of radiobuttons, how can I do this quickly

As I understand, when you have Thousands of radiobuttons in the panel. The main problem is the delay and slowness of the UI, affecting operations and experience.

So, I suggest you can try to use the UI Virtualization in WPF and second is Data Virtualization. The UI virtualization minimizes the number of things drawn and data virtualization minimizes the number of things that could be drawn.

A simple Sample:

 <StackPanel>
            <ScrollViewer CanContentScroll="True">
                <VirtualizingStackPanel x:Name="visualsp"  VirtualizationMode="Recycling" Width="800" Height="300">
                </VirtualizingStackPanel>
            </ScrollViewer>
            <Button x:Name="LoadDataButton" Content="Load Data"   VerticalAlignment="Top" 
Click="LoadDataButton_Click"/>
        </StackPanel>


 private void LoadDataButton_Click(object sender, RoutedEventArgs e)
        {
            for (var count = 1; count < 10001; ++count)
            {
                RadioButton rb = new RadioButton();
                rb.Content = "count" + count.ToString();
                rb.IsChecked = false;
                visualsp.Children.Add(rb);
            }
        }




以下文章供您参考。



数据和用户界面虚拟化 $ b

最好的问候,



Yong Lu



$


The following articles for your reference.

Data and UI Virtualization in WPF


Best Regards,

Yong Lu



这篇关于如何以最高效率实现这个问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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