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

问题描述

如图所示,每五个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?

推荐答案

 <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



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

09-01 21:56