相关疑难解决方法(0)

WPF数据虚拟化ListView

在我们当前的WinForms应用程序中,我们使用虚拟化在ListView中显示数百万条记录.在请求时从DB加载行.这很好,性能很好.

这是一个为我们迁移到WPF的showstopper.我们需要在ListView中进行数据虚拟化,就像WinForms 2.0一样.

你知道一个体面的第三方控件,或者使用内置控件进行相对简单的方法吗?它不需要是一个DataGrid,一个简单的ListView就足够了.

请注意,我注意到了UI虚拟化,它是数据虚拟化.

wpf virtualization performance listview

12
推荐指数
1
解决办法
2万
查看次数

最小化内存消耗图像列表框(WPF)

我有列表框绑定到ObservableCollection并使用文件名来显示图像 在此输入图像描述

我的xaml是:

<Window x:Class="ThumbnailsView.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="578" WindowStartupLocation="CenterScreen">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="55"/>
        </Grid.RowDefinitions>

            <ListBox Grid.Row="0" x:Name="ImageListbox"
        ItemsSource="{Binding}" 
        Background="AliceBlue" ScrollViewer.HorizontalScrollBarVisibility="Disabled">

                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <CheckBox Height="16" VerticalAlignment="Top" Margin="0,10,0,0"/>
                            <Image Margin="10,10,10,0" Height="64" Width="64" VerticalAlignment="Top">
                                <Image.Source>
                                    <BitmapImage DecodePixelWidth="64" UriSource="{Binding Path=Name}"/>
                                </Image.Source>                            
                            </Image>
                    </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>

        <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel/>
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
            </ListBox>

            <Button Grid.Row="1" Content="Get Images" Name="getImageBtn" Click="getImageBtn_Click" Width="100" Height="30"></Button>

    </Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)

问题是,如果我有一个大型集合,它会加载整个图像并消耗大量的内存.如何最大限度地减少内存消耗?

c# wpf listbox

6
推荐指数
1
解决办法
7065
查看次数

标签 统计

wpf ×2

c# ×1

listbox ×1

listview ×1

performance ×1

virtualization ×1