Click here to Skip to main content
15,886,110 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.MovieResult.MovieResultView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:cal="clr-namespace:Microsoft.Practices.Composite.Presentation.Regions;assembly=Microsoft.Practices.Composite.Presentation" xmlns:Constants="clr-namespace:MediaAssistant.Constants" xmlns:Converters="clr-namespace:MediaAssistant.Converters" xmlns:MediaAssistant="clr-namespace:MediaAssistant" mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="600" Background="{StaticResource BodyBackground}">
	<UserControl.Resources>
        <Converters:BoolInverseConverter x:Key="BoolInverseConverter" />
        <Converters:AlternativeLocationTextConverter x:Key="AlternativeLocationTextConverter" />
	</UserControl.Resources>
	<DockPanel>
        <Border DockPanel.Dock="Top" Height="35" Background="#ECECEC">
            <DockPanel>
                <StackPanel DockPanel.Dock="Left" HorizontalAlignment="Left" Orientation="Horizontal" Height="30">
                    <Button  Width="30" Height="30" Margin="5,0" Command="{Binding DataSource.PlayMovieCommand}" 
                             ToolTip="Play movie with default player"
                             Style="{StaticResource ImageButtonStyle}">
                        <ContentControl Content="{StaticResource PlayMovieImage}"/>
                    </Button>
                    <Button  Width="30" Height="30" Margin="5,0" ToolTip="Show movie in windows explorer"
                             Command="{Binding DataSource.ShowMovieInWindowsExplorerCommand}" 
                             Style="{StaticResource ImageButtonStyle}">
                        <ContentControl Content="{StaticResource MovieFolderImage}"/>
                    </Button>
                    <Button  Width="30" Height="30" Margin="5,0" Command="{Binding DataSource.ShowMovieInIMDBCommand}" ToolTip="Show movie in IMDB web site"
                             Style="{StaticResource ImageButtonStyle}">
                        <ContentControl Content="{StaticResource IMDBImage}"/>
                    </Button>
                    <Separator BorderThickness="2"/>
                    <ToggleButton x:Name="starButton" Width="30" Height="30" ToolTip="Mark as favorite movie"
                                      IsChecked="{Binding DataSource.SelectedMovie.IsStarred}"
                                      Style="{StaticResource opacityToggleButton}"
                                      Command="{Binding DataSource.SaveMovieStateCommand}">
                        <ContentControl Content="{StaticResource StarImage}"/>
                    </ToggleButton>
                    <ToggleButton Width="30" Height="30" Margin="10,0,0,0" ToolTip="Move to wish list"
                                      IsChecked="{Binding DataSource.SelectedMovie.IsInWishList}"
                                      Style="{StaticResource opacityToggleButton}"
                                      Command="{Binding DataSource.SaveMovieStateCommand}">
                        <ContentControl Content="{StaticResource WishListImage}"/>
                    </ToggleButton>
                    <ToggleButton Width="30" Height="30" Margin="10,0,10,0" ToolTip="Mark as watched movie"
                                      IsChecked="{Binding DataSource.SelectedMovie.Watched}"
                                      Style="{StaticResource opacityToggleButton}"
                                      Command="{Binding DataSource.SaveMovieStateCommand}">
                        <ContentControl Content="{StaticResource WatchListImage}"/>
                    </ToggleButton>
                    <Button 
                        Content="{Binding DataSource.SelectedMovie, Converter={StaticResource AlternativeLocationTextConverter}}" 
                        Command="{Binding DataSource.ShowAlternativeLocationsCommand}" Margin="5"
                        Style="{StaticResource LinkButtonStyle}" FontSize="15"/>
                </StackPanel>
                
                <StackPanel DockPanel.Dock="Right" HorizontalAlignment="Right" Orientation="Horizontal" Height="30">
                    <ToggleButton Width="30" Height="30" Margin="5,0" ToolTip="Show drives movie only"
                                      IsChecked="{Binding DataSource.ShowDrivesMoviesOnly}"
                                      Style="{StaticResource opacityToggleButton}">
                        <ContentControl Content="{StaticResource DrivesMoviesImage}"/>
                    </ToggleButton>
                    <ToggleButton  Width="30" Height="30" Margin="5,0" Style="{StaticResource toggleOptionButtonStyle}"  Cursor="Hand" ToolTip="Show result as grid view"
                               IsChecked="{Binding IsListView}">
                        <ContentControl Content="{StaticResource ListViewImage}"/>
                    </ToggleButton>
                    <ToggleButton x:Name="listView" Width="30" Height="30" Margin="5,0"  Style="{StaticResource toggleOptionButtonStyle}"  Cursor="Hand" ToolTip="Show result as thumbnail view"
                               IsChecked="{Binding IsListView, Converter={StaticResource BoolInverseConverter}}"
                               >
                        <ContentControl Content="{StaticResource ThumbnailViewImage}"/>
                    </ToggleButton>
                </StackPanel>
            </DockPanel>
            
        </Border>
        <Border DockPanel.Dock="Top">
            <ContentControl cal:RegionManager.RegionName="{x:Static Constants:MediaAssistantRegionNames.MovieResultResion}"/>
        </Border>
    </DockPanel>
</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