Click here to Skip to main content
15,884,836 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.1K   5.6K   41  
WrapPanel doesn't support virtualization. But we can improve the performance by simulating virtualization.
<UserControl x:Class="MediaAssistant.Controls.AddMovie.AddMovieView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:Converters="clr-namespace:MediaAssistant.Converters" 
             Width="600" Height="280" Background="{StaticResource BodyBackground}">
    <UserControl.Resources>
        <Converters:NullVisibilityConverter x:Key="NullVisibilityConverter" />
    </UserControl.Resources>
    <DockPanel>
        <Border DockPanel.Dock="Top" BorderThickness="2" BorderBrush="LightGray" Padding="5" Margin="2">
            <TextBlock TextWrapping="Wrap">Add movie which are not available at your repository or local storage. If you want to add a movie file then use Add File or Add Folder menu. Media Assistant will scan your file to get movie details.</TextBlock>
        </Border>
        <Border BorderBrush="LightGray" BorderThickness="2" DockPanel.Dock="Left" Width="160" Padding="2" Margin="2">
            <Grid>
                <ContentControl Content="{StaticResource MoviePosterImage}"
                                    Visibility="{Binding Movie.PosterImage, Converter={StaticResource NullVisibilityConverter}}"/>
                <Image HorizontalAlignment="Center" VerticalAlignment="Center">
                    <Image.Source>
                        <MultiBinding Converter="{StaticResource PosterImageConverter}">
                            <Binding Path="Movie"/>
                            <Binding Path="Movie.Poster"/>
                            <Binding Path="Movie.PosterImage"/>
                        </MultiBinding>
                    </Image.Source>
                </Image>
            </Grid>
        </Border>
        <Grid>
            <StackPanel DockPanel.Dock="Left" Margin="5">
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="Title" Margin="0,5,5,5" VerticalAlignment="Center" FontSize="15" FontWeight="Bold"/>
                    <TextBox Text="{Binding Movie.Title}" FontSize="15" FontWeight="Bold" Width="300" Margin="0,5"/>
                    <Button Content="Search IMDb" 
                                FontSize="15" Margin="5,10" Style="{StaticResource LinkButtonStyle}" 
                                Command="{Binding SearchIMDbCommand}"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding Movie.Rated}" Margin="0,5" FontWeight="Bold"/>
                    <TextBlock Text="{Binding Movie.Runtime}" Margin="10,5" Foreground="Gray"/>
                    <TextBlock Text="{Binding Genres}" Margin="0,5,0,5"/>
                    <TextBlock Text="{Binding Movie.Released, StringFormat='- {0:MMMM d, yyyy}'}" Margin="5"/>
                </StackPanel>
                <Border Margin="0,5" BorderThickness="1" BorderBrush="LightGray"/>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding Movie.Rating, StringFormat='Rating: {0}/10'}" FontSize="15" VerticalAlignment="Center"/>
                    <TextBlock Text="{Binding Movie.Votes, StringFormat='Votes: {0}'}" Margin="20,0"  FontSize="15" VerticalAlignment="Center"/>
                </StackPanel>
                <Border Margin="0,5" BorderThickness="1" BorderBrush="LightGray"/>
                <TextBlock Text="{Binding Movie.Plot}" TextWrapping="Wrap"/>
                <StackPanel Orientation="Horizontal" Margin="0,5">
                    <TextBlock Text="Director:" Margin="0,0,5,0"/>
                    <TextBlock Text="{Binding Directors}"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="Writers:" Margin="0,0,5,0"/>
                    <TextBlock Text="{Binding Writers}"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal" Margin="0,5">
                    <TextBlock Text="Stars:" Margin="0,0,5,0"/>
                    <TextBlock Text="{Binding Stars}"/>
                </StackPanel>
            </StackPanel>
        </Grid>
    </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