WPF列表视图删除高亮电影海报布局和缩放

时间:2016-11-02 17:26:01

标签: wpf vb.net

嘿所有我想用WPF制作自己的电影海报菜单。到目前为止它很好,但有一些问题我想帮助清理。

对于初学者来说,这是我的代码:

<Window x:Class="MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:scrollView"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525">
    <ListView x:Name="TvBox" HorizontalAlignment="Stretch" VerticalAlignment="Top" IsTextSearchEnabled="False" SelectionMode="Single" UseLayoutRounding="True">
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <UniformGrid Columns="5" HorizontalAlignment="Stretch"/>
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
        <ListView.ItemTemplate>
            <DataTemplate>
                <StackPanel Orientation="Vertical" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
                    <Image Source="{Binding ImageData}" HorizontalAlignment="Stretch" VerticalAlignment="Top" Stretch="UniformToFill" Width="150">
                        <Image.Effect>
                            <DropShadowEffect BlurRadius="20" ShadowDepth="0" Opacity="0.5"/>
                        </Image.Effect>
                        <Image.Style>
                    </Image>
                    <TextBlock Text="{Binding Title}" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" />
                </StackPanel>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>    
</Window>

背后的代码如下:

Class MainWindow
    Public Class MovieData
        Private _Title As String
        Private _ImageData As BitmapImage

        Public Property Title() As String
            Get
                Return Me._Title
            End Get
            Set
                Me._Title = Value
            End Set
        End Property

        Public Property ImageData() As BitmapImage
            Get
                Return Me._ImageData
            End Get
            Set
                Me._ImageData = Value
            End Set
        End Property
    End Class
    Private Sub MainWindow_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
        Me.TvBox.ItemsSource = New MovieData() {New MovieData() With {
            .Title = "Movie 1",
            .ImageData = GetBitmapImage(New Uri("C:\Users\someone\Pictures\box1.jpg"))
        }, New MovieData() With {
            .Title = "Movie 2",
            .ImageData = GetBitmapImage(New Uri("C:\Users\someone\Pictures\box2.jpg"))
        }, New MovieData() With {
            .Title = "Movie 3",
            .ImageData = GetBitmapImage(New Uri("C:\Users\someone\Pictures\box3.jpg"))
        }, New MovieData() With {
            .Title = "Movie 4",
            .ImageData = GetBitmapImage(New Uri("C:\Users\someone\Pictures\box4.jpg"))
        }, New MovieData() With {
            .Title = "Movie 5",
            .ImageData = GetBitmapImage(New Uri("C:\Users\someone\Pictures\box5.jpg"))
        }, New MovieData() With {
            .Title = "Movie 6",
            .ImageData = GetBitmapImage(New Uri("C:\Users\someone\Pictures\box6.jpg"))
        }, New MovieData() With {
            .Title = "Movie 7",
            .ImageData = GetBitmapImage(New Uri("C:\Users\someone\Pictures\box7.jpg"))
        }, New MovieData() With {
            .Title = "Movie 8",
            .ImageData = GetBitmapImage(New Uri("C:\Users\someone\Pictures\box8.jpg"))
        }, New MovieData() With {
            .Title = "Movie 9",
            .ImageData = GetBitmapImage(New Uri("C:\Users\someone\Pictures\box9.jpg"))
        }, New MovieData() With {
            .Title = "Movie 10",
            .ImageData = GetBitmapImage(New Uri("C:\Users\someone\Pictures\box10.jpg"))
        }, New MovieData() With {
            .Title = "Movie 11",
            .ImageData = GetBitmapImage(New Uri("C:\Users\someone\Pictures\box11.jpg"))
        }, New MovieData() With {
            .Title = "Movie 12",
            .ImageData = GetBitmapImage(New Uri("C:\Users\someone\Pictures\box12.jpg"))
        }, New MovieData() With {
            .Title = "Movie 13",
            .ImageData = GetBitmapImage(New Uri("C:\Users\someone\Pictures\box13.jpg"))
        }, New MovieData() With {
            .Title = "Movie 14",
            .ImageData = GetBitmapImage(New Uri("C:\Users\someone\Pictures\box14.jpg"))
        }, New MovieData() With {
            .Title = "Movie 15",
            .ImageData = GetBitmapImage(New Uri("C:\Users\someone\Pictures\box15.jpg"))
        }}
    End Sub

    Public Function GetBitmapImage(imageAbsolutePath As Uri, Optional bitmapCacheOption__1 As BitmapCacheOption = BitmapCacheOption.[Default]) As BitmapImage
        Dim image As New BitmapImage()
        image.BeginInit()
        image.CacheOption = bitmapCacheOption__1
        image.UriSource = imageAbsolutePath
        image.EndInit()

        Return image
    End Function
End Class

以上所有内容产生以下内容:

enter image description here

我遇到的问题:

enter image description here

注意海报周围的亮点?浅蓝色?如何关闭它但仍能使用上/下/左/右箭头选择海报?

除了上面的内容,当我突出显示(海报上的浅蓝色)时,我希望选择的海报向用户显示(我称之为缩放)。这可能与WPF有关吗?

0 个答案:

没有答案