1

我是这个论坛的新手,也是编程方面的新手。

尽管如此,我还是去了一个使用 WPF/Visual Basic 的个人音乐播放器,我在以下问题上敢于并且非常(!)长时间地战斗:

相当于媒体播放器我想在相应的标题专辑封面和其他信息视图右侧的列表中为相应的艺术家提供。

为此,我有一个 DataGrid (Master) 用于解释的各个专辑 - 尽可能容易;现在要从各自的歌曲详细信息中显示专辑封面,我需要在 TemplateColumn ** ** 另一个 DataGrid(子)中“嵌套”的可能性,但是我关于 Petrol Ofisi

非常接近此链接http://social.msdn.microsoft.com/Forums/vstudio/en-US/36909161-3afc-4fcc-af0a-da377a65e421/wpf-grid-column-databinding-to的解决方案-comple存在,但对我来说只能理解有限的程度,因为

  • 用 C# 编程是,
  • 通过定义的 Collection-Klassen 和最后但并非最不重要的数据绑定
  • 该解决方案使用转换器,它的实现问题对我来说真的很难。

    <Grid x:Name="LayoutRoot" HorizontalAlignment="Left" Margin="0,0,-7.6,-2.4" VerticalAlignment="Top" Width="1344.8" ScrollViewer.HorizontalScrollBarVisibility="Hidden" Height="790">
    <DataGrid x:Name="AlbenInterpretenAlbenDG" VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.IsVirtualizingWhenGrouping="True" VirtualizingPanel.VirtualizationMode="Recycling" CanUserAddRows="False" HorizontalAlignment="Left" Height="413.6" Margin="-7.2,362.4,0,0" Width="1345.2" BorderThickness="0" FontFamily="Baskerville Old Face" FontSize="26.667" Foreground="#FF2F3699" AutoGenerateColumns="False" VerticalAlignment="Top" HorizontalScrollBarVisibility="Hidden" IsReadOnly="True" Background="{x:Null}" MaxHeight="800" HorizontalGridLinesBrush="#FFFFC20E" IsSynchronizedWithCurrentItem="False" HeadersVisibility="None">
        <DataGrid.GroupStyle>
            <GroupStyle>
                <GroupStyle.HeaderTemplate>
                    <DataTemplate>
                        <TextBlock x:Name="GroupHeaderAlbum" Background="#FFFFC20E" Foreground="#FF2F3699" FontSize="40.333" FontFamily="Baskerville Old Face" FontWeight="Bold" FontStyle="Italic"/>
                    </DataTemplate>
                </GroupStyle.HeaderTemplate>
            </GroupStyle>
        </DataGrid.GroupStyle>
        <DataGrid.Columns>
            <DataGridTemplateColumn x:Name="AlbumCover" CanUserSort="True" CanUserReorder="False" ClipboardContentBinding="{x:Null}" SortMemberPath="Album.SortName" Header="AlbumCover" SortDirection="Ascending">
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <Grid x:Name="GridAlbumCover" Background="#FFFFC20E" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Width="190" Height="190">
                            <Image Source="{Binding AlbumcoverBildDatei}" Stretch="Fill" Height="180" Width="180" Margin="5,5,5,5"/>
                        </Grid>
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <DataGridTextColumn x:Name="AlbumID" Binding="{Binding AlbumID}" ClipboardContentBinding="{x:Null}" FontSize="41.333" FontFamily="Baskerville Old Face" Header="AlbumID" Visibility="Hidden" d:IsHidden="True"/>
            <DataGridTextColumn x:Name="Album" Binding="{Binding Album}" ClipboardContentBinding="{x:Null}" FontSize="41.333" FontFamily="Baskerville Old Face" Header="Album" Visibility="Hidden" d:IsHidden="True"/>
            <DataGridTextColumn x:Name="Orchestra" Binding="{Binding Orchestra}" ClipboardContentBinding="{x:Null}" FontSize="41.333" FontFamily="Baskerville Old Face" Header="Orchestra" Visibility="Hidden" d:IsHidden="True"/>
            <DataGridTemplateColumn x:Name="AlbenInterpretenAlbenSongs" Header="" Visibility="Visible" CanUserReorder="False">
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <DataGrid x:Name="AlbenInterpretenAlbenSongsDG" **Binding=??????** VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.IsVirtualizingWhenGrouping="True" VirtualizingPanel.VirtualizationMode="Recycling" CanUserAddRows="False" HorizontalAlignment="Left" Height="200" Margin="0,0,-169.6,-3.6" Width="1324.4" BorderThickness="0" FontFamily="Baskerville Old Face" FontSize="26.667" Foreground="#FF2F3699" AutoGenerateColumns="False" VerticalAlignment="Top" HorizontalScrollBarVisibility="Hidden" IsReadOnly="True" Background="{x:Null}" IsSynchronizedWithCurrentItem="True" MaxHeight="800" HorizontalGridLinesBrush="#FFFFC20E" VerticalGridLinesBrush="#FFFFC20E" HeadersVisibility="None">
                            <DataGrid.RowBackground>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FFBCBEDC" Offset="0.085"/>
                                    <GradientStop Color="White" Offset="1"/>
                                </LinearGradientBrush>
                            </DataGrid.RowBackground>
                            <DataGrid.BorderBrush>
                                <SolidColorBrush Color="#FF688CAF" Opacity="0"/>
                            </DataGrid.BorderBrush>
                            <DataGrid.Columns>
                                <DataGridTextColumn x:Name="OrchestraDG" Binding="{Binding Orchestra}" ClipboardContentBinding="{Binding Orchestra}" FontSize="37.333" FontFamily="Baskerville Old Face" Header="Album-Interpret" SortMemberPath="Orchestra" CanUserSort="True" Visibility="Hidden" Width="370"/>
                                <DataGridTextColumn x:Name="AlbumIDDG" Binding="{Binding AlbumID}" ClipboardContentBinding="{Binding AlbumID}" FontSize="41.333" FontFamily="Baskerville Old Face" Header="AlbumID" SortMemberPath="AlbumID" CanUserSort="True" Visibility="Hidden"/>
                                <DataGridTextColumn x:Name="AlbumNameDG" Binding="{Binding Album}" ClipboardContentBinding="{Binding Album}" FontSize="41.333" FontFamily="Baskerville Old Face" Header="Album" SortMemberPath="Alben.SortName" CanUserSort="True" Width="190" Visibility="Hidden"/>
                                <DataGridTextColumn x:Name="NrDG" Binding="{Binding Track}" ClipboardContentBinding="{Binding Track}" FontSize="41.333" FontFamily="Baskerville Old Face" Header="Nr." SortMemberPath="Track" CanUserSort="True" Width="50">
                                    <DataGridTextColumn.CellStyle>
                                        <Style>
                                            <Setter Property="Block.TextAlignment" Value="Right"/>
                                        </Style>
                                    </DataGridTextColumn.CellStyle>
                                </DataGridTextColumn>
                                <DataGridTextColumn x:Name="SongTitelDG" Binding="{Binding Title}" ClipboardContentBinding="{Binding Title}" FontSize="41.333" FontFamily="Baskerville Old Face" Header="Song-Titel" Width="505"/>
                                <DataGridTextColumn x:Name="InterpretDG" Binding="{Binding Artist}" ClipboardContentBinding="{Binding Artist}" FontSize="37.333" FontFamily="Baskerville Old Face" Header="Interpret" Width="380"/>
                                <DataGridTextColumn x:Name="LängeDG" Binding="{Binding Length, StringFormat=m:ss}" ClipboardContentBinding="{Binding Length}" FontSize="37.333" FontFamily="Baskerville Old Face" Header="Länge" Width="90">
                                    <DataGridTextColumn.CellStyle>
                                        <Style>
                                            <Setter Property="Block.TextAlignment" Value="Right"/>
                                        </Style>
                                    </DataGridTextColumn.CellStyle>
                                </DataGridTextColumn>
                                <DataGridTextColumn x:Name="JahrDG" Binding="{Binding SongsAlben/ErscheinungsJahr}" ClipboardContentBinding="{Binding ErscheinungsJahr}" FontSize="37.333" FontFamily="Baskerville Old Face" Header="Jahr" Width="100">
                                    <DataGridTextColumn.CellStyle>
                                        <Style>
                                            <Setter Property="Block.TextAlignment" Value="Right"/>
                                        </Style>
                                    </DataGridTextColumn.CellStyle>
                                </DataGridTextColumn>
                            </DataGrid.Columns>
                        </DataGrid>
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
        </DataGrid.Columns>
    </DataGrid>
    
    Public Function GetAbfrageAlbenInterpretenAlbenSongs() As DataTable
    Dim adapter As New OleDbDataAdapter("Select * From AbfrageAlbenInterpretenAlbenSongs ORDER BY AbfrageAlbenInterpretenAlben.AlbenInterpreten.SortName, AbfrageAlbenInterpretenAlben.Alben.SortName, Songs.Track", Application.con)
    Dim AbfrageAlbenInterpretenAlbenSongsDataSet As New DataSet()
    adapter.Fill(AbfrageAlbenInterpretenAlbenSongsDataSet, "AbfrageAlbenInterpretenAlbenSongs")
    Return AbfrageAlbenInterpretenAlbenSongsDataSet.Tables(0)
    Application.con.Close()
    

    结束功能

    Private Sub PageAlbumInterpret_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs)
    

Dim AlbenInterpretenAlbenDS As DataSet AlbenInterpretenAlbenDS = GetAbfrageAlbenInterpretenAlbenSongs() ' Set the DataContext of AlbenInterpretenAlbenDG to DataTable AlbenInterpretenAlbenDG.DataContext = AlbenInterpretenAlbenDS.Tables(0) AlbenInterpretenAlbenDG.ItemsSource = AlbenInterpretenAlbenDS.Tables(0).DefaultView

End Sub

    Private Sub Artist_TextChanged(ByVal sender As Object, ByVal e As System.Windows.Controls.TextChangedEventArgs)

    'ALBEN UND SONGS
    Dim cvAlben As BindingListCollectionView = CType(CollectionViewSource.GetDefaultView(AlbenInterpretenAlbenDG.ItemsSource),BindingListCollectionView)
    CVAlben.CustomFilter = "Orchestra = '" & Artist.Text.Replace("'", "''") & "' Or Orchestra Like '" & Artist.Text.Replace("'", "''") & ";%' Or Orchestra Like '%; " & Artist.Text.Replace("'", "''") & ";%' Or Orchestra Like '%; " & Artist.Text.Replace("'", "''") & "'"
    Dim ArtistString As String
    ArtistString = Me.Artist.Text
    Dim DRV As DataRowView
    For Each DRV In AlbenInterpretenAlbenDG.Items
        If ArtistString = DRV("Orchestra") Then
            AlbenInterpretenAlbenDG.GroupStyle.Item(0) = CType(PageAlbumInterpret.FindResource("GroupHeaderStyleAlbum"), GroupStyle)
        Else
           AlbenInterpretenAlbenDG.GroupStyle.Item(0) = CType(PageAlbumInterpret.FindResource("GroupHeaderStyleOrchestraAlbum"), GroupStyle)
            Exit Sub
        End If
    Next
    CVAlben.MoveCurrentToFirst
    Dim border As Decorator = VisualTreeHelper.GetChild(AlbenInterpretenAlbenDG, 0)
    If border IsNot Nothing Then
        Dim scrollViewer As ScrollViewer = border.Child
        scrollViewer.ScrollToTop()
    End If
4

0 回答 0