Click here to Skip to main content
15,885,885 members
Articles / Desktop Programming / WPF

Wrap Panel Virtualization

Rate me:
Please Sign up or sign in to vote.
4.95/5 (18 votes)
2 Jan 2012CPOL2 min read 53.2K   5.6K   41  
WrapPanel doesn't support virtualization. But we can improve the performance by simulating virtualization.
<UserControl x:Class="MediaAssistant.Controls.ProfileSelector.ProfileSelectorView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             xmlns:Converters="clr-namespace:MediaAssistant.Converters" xmlns:Constants="clr-namespace:MediaAssistant.Constants" Width="Auto" Height="Auto">
	<UserControl.Resources>
        <Converters:ScanOptionToCheckedConverter x:Key="ScanOptionToCheckedConverter" />
        <Converters:ParameterEqualityConverter x:Key="ParameterEqualityConverter" />
        <DataTemplate x:Key="ScanDirectoryTemplate">
            <StackPanel Orientation="Horizontal" Height="24">
                <Button Width="24"
                        Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.DeleteScanFolderCommand}"
                        CommandParameter="{Binding}"
                        Content="{StaticResource DeleteFolderImage}" Style="{StaticResource ImageButtonStyle}">
                </Button>
                <ToggleButton Margin="5,0" Content="{StaticResource Eye16Image}" Style="{StaticResource opacityToggleButton}" IsChecked="{Binding KeepEye, Mode=TwoWay}"/>
                <TextBlock VerticalAlignment="Center" Text="{Binding FullPath}"/>
            </StackPanel>
        </DataTemplate>
    </UserControl.Resources>
	<Border Padding="10,30" Background="{StaticResource LightBackground}">
        <StackPanel>
            <StackPanel Orientation="Horizontal">
                <TextBlock Margin="10" Text="Profile Name"/>
                <ComboBox Margin="0,10,10,10" Width="180" IsEditable="True" 
                      ItemsSource="{Binding DataSource.MediaAssistantEntities.Profiles}" 
                      DisplayMemberPath="Name"
                      Text="{Binding ProfileName}"/>
            </StackPanel>
            <StackPanel Orientation="Vertical">
                <StackPanel Margin="10,10,10,0" Orientation="Vertical">
                    <RadioButton GroupName="Scan" Content="Scan My Computer for music and movie" 
                                 Command="{Binding ChangeScanOptionCommand}"
                                 CommandParameter="{x:Static Constants:ScanOption.MyComputer}"
                                 IsChecked="{Binding ScanOption, Converter={StaticResource ScanOptionToCheckedConverter}, ConverterParameter={x:Static Constants:ScanOption.MyComputer}, Mode=OneWay}"/>
                    <TextBlock Margin="16,0" Text="Choose this option if you have stored your music and movie in multiple folder and multiple drive"/>
                </StackPanel>
                <StackPanel Margin="10,10,10,0" Orientation="Vertical">
                    <RadioButton GroupName="Scan" Content="Only scan My Documents, My Music and My Video for music and movie" 
                                 Command="{Binding ChangeScanOptionCommand}"
                                 CommandParameter="{x:Static Constants:ScanOption.MyDocument}"
                                 IsChecked="{Binding ScanOption, Converter={StaticResource ScanOptionToCheckedConverter}, ConverterParameter={x:Static Constants:ScanOption.MyDocument}, Mode=OneWay}"/>
                    <TextBlock Margin="16,0" Text="Choose this option if you have stored your music and movie in above folders"/>
                </StackPanel>
                <StackPanel Margin="10,10,10,0" Orientation="Vertical">
                    <RadioButton GroupName="Scan" Content="Scan specific folders" 
                                 Command="{Binding ChangeScanOptionCommand}"
                                 CommandParameter="{x:Static Constants:ScanOption.SpecificFolder}"
                                 IsChecked="{Binding ScanOption, Converter={StaticResource ScanOptionToCheckedConverter}, ConverterParameter={x:Static Constants:ScanOption.SpecificFolder}, Mode=OneWay}"/>
                    <TextBlock Margin="16,0" Text="Choose this option if you want to specify the music and movie folder."/>
                    <StackPanel Margin="0,5,0,5" IsEnabled="{Binding ScanOption, Converter={StaticResource ParameterEqualityConverter}, ConverterParameter=SpecificFolder}">
                        <ListBox Margin="16,0" Height="120" ItemsSource="{Binding ScannedDirectories}" ItemTemplate="{StaticResource ScanDirectoryTemplate}"/>
                        <TextBlock Margin="16,5,0,0"><Hyperlink Command="{Binding AddFolderCommand}">Add Folder</Hyperlink></TextBlock>
                    </StackPanel>
                </StackPanel>
                <StackPanel Margin="10,10,10,0" Orientation="Vertical">
                    <RadioButton GroupName="Scan" Content="Do not scan my computer for music and movie" 
                                 Command="{Binding ChangeScanOptionCommand}"
                                 CommandParameter="{x:Static Constants:ScanOption.None}"
                                 IsChecked="{Binding ScanOption, Converter={StaticResource ScanOptionToCheckedConverter}, ConverterParameter={x:Static Constants:ScanOption.None}, Mode=OneWay}"/>
                    <TextBlock Margin="16,0" Text="Choose this option if you want to turn of scan your computer and you want to add music and movie manually"/>
                </StackPanel>
                <StackPanel Margin="10,10,10,0" Orientation="Vertical">
                    <CheckBox Content="Import IMDB movies" 
                          IsChecked="{Binding IsImportIMDbMovies}"/>
                    <TextBlock Margin="16,0" Text="Choose this option if you want to import movies from IMDB which are not available at your storage."/>
                </StackPanel>
            </StackPanel>
        </StackPanel>
    </Border>
</UserControl>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) KAZ Software Limited
Bangladesh Bangladesh
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions