i am binding a lot of images in listview using following code
lvImages.ItemsSource = lstVisualDuplicateImage;
following properties used in ListView
here is my complete XAML Binding ang Grouping is performed iam using .net 4.5
<ListView Name="lvImages" Margin="0,2,0,38"
VirtualizingPanel.IsContainerVirtualizable="True"
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.IsVirtualizingWhenGrouping="True"
VirtualizingPanel.VirtualizationMode="Recycling" Grid.Row="1"
SelectionChanged="ListViewFiles_SelectionChanged"
ContextMenuOpening="ListViewFiles_ContextMenuOpening"
ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Disabled" Grid.RowSpan="3">
<ListView.ContextMenu>
<ContextMenu>
<MenuItem x:Name="menuOpen" Header="Open" Click="menuOpen_Click" />
<MenuItem x:Name="menuOpenFileLocation" Header="Open File Location" Click="menuOpenFileLocation_Click" />
<MenuItem x:Name="menuRemove" Header="Remove" Click="menuRemove_Click" />
<MenuItem x:Name="menuOpenProperties" Header="Properties" Click="menuOpenProperties_Click" />
</ContextMenu>
</ListView.ContextMenu>
<ListView.ItemsPanel>
<ItemsPanelTemplate >
<!--<VirtualizingStackPanel Orientation="Horizontal" >-->
<WrapPanel Orientation="Horizontal"/>
<!--</VirtualizingStackPanel>-->
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.View>
<GridView >
<GridView.ColumnHeaderContainerStyle>
<Style TargetType="GridViewColumnHeader">
<Setter Property="Visibility" Value="Collapsed" />
</Style>
</GridView.ColumnHeaderContainerStyle>
<GridViewColumn Width="160" Header="Group Details" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<Border CornerRadius="2" BorderThickness="2" BorderBrush="#B3B4B5">
<StackPanel >
<StackPanel Orientation="Horizontal">
<CheckBox Margin="0" MinWidth="22" Name="chkSelRow" IsChecked="{Binding Path=Checked}" Unchecked="lvFileItem_UnChecked" Checked="lvFileItem_Checked" />
<TextBlock Margin="5,0,0,0" Text="{Binding Path=size}" />
</StackPanel>
<Image Height="120" Width="120">
<Image.Source>
<BitmapImage
DecodePixelHeight="120"
DecodePixelWidth="120"
UriSource="{Binding Path=getUri, Mode=OneWay,UpdateSourceTrigger=Explicit }"
CreateOptions="IgnoreColorProfile"
CacheOption="None" />
</Image.Source>
</Image>
<StackPanel Orientation="Vertical">
<TextBlock Margin="5,0,0,3" Text="{Binding Path=FileName}" />
</StackPanel>
</StackPanel>
</Border>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
<ListView.GroupStyle>
<GroupStyle>
<GroupStyle.ContainerStyle>
<Style TargetType="{x:Type GroupItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Expander IsExpanded="True" Style="{DynamicResource newExpanderStyle}" >
<Expander.Header>
<StackPanel Orientation="Horizontal">
<Button Content="View Gropu" Style="{StaticResource LinkButton}" Foreground="Blue" Margin="10,5,0,0" x:Name="btnViewGroup" ></Button>
<TextBlock Text=" Group NO " FontSize="12" Foreground="Black" Margin="30,0,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" />
<TextBlock Text="(" FontSize="14" Margin="0,2,0,0" Foreground="Black" />
<TextBlock Text="{Binding Name}" FontWeight="Bold" Foreground="Black" FontSize="12" HorizontalAlignment="Center" VerticalAlignment="Center" />
<TextBlock Text=")" FontSize="14" Margin="0,2,0,0" Foreground="Black" />
<TextBlock Text=" Items in Group" FontSize="12" Foreground="Black" Margin="60,0,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" />
<TextBlock Text="(" FontSize="14" Margin="0,2,0,0" Foreground="Black" />
<TextBlock Text="{Binding ItemCount}" FontSize="12" Foreground="Black" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" />
<TextBlock Text=")" FontSize="14" Margin="0,2,0,0" Foreground="Black" />
</StackPanel>
</Expander.Header>
<ItemsPresenter />
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
</GroupStyle>
</ListView.GroupStyle>
</ListView>
no of item is complete in listview Problem is images repeat and change their position in groups not loading correctly and refreshing is there any way to virtualize groups.
You have changed the
ListView.ItemsPanel
from aVirtualizingStackPanel
to aWrapPanel
. Virtualization only works correctly when the panel supports virtualization. In this case, the standardWrapPanel
does not support virtualization.