Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
wpf项目控制数据模板页边距_Wpf_Datatemplate_Itemtemplate - Fatal编程技术网

wpf项目控制数据模板页边距

wpf项目控制数据模板页边距,wpf,datatemplate,itemtemplate,Wpf,Datatemplate,Itemtemplate,不要介意左边和右边的边栏,它们只是暂时的,直到我做了正确的边栏 正如您在下面的代码中所看到的,以及我在datatemplate中列出的所有艺术家(来自observablecollection)的图像 我的问题是:我将如何制作它,以便在调整gui大小时图像变大,或者增加更多的边距。因为现在,右手边要么没有空间(我想要的),要么空间太大。 我知道为什么会发生这种情况,新的项目不太小,无法添加,所以会添加到下一行。但我真的不知道如何在我的代码中解决这个问题 <ItemsControl Items

不要介意左边和右边的边栏,它们只是暂时的,直到我做了正确的边栏

正如您在下面的代码中所看到的,以及我在datatemplate中列出的所有艺术家(来自observablecollection)的图像

我的问题是:我将如何制作它,以便在调整gui大小时图像变大,或者增加更多的边距。因为现在,右手边要么没有空间(我想要的),要么空间太大。 我知道为什么会发生这种情况,新的项目不太小,无法添加,所以会添加到下一行。但我真的不知道如何在我的代码中解决这个问题

<ItemsControl ItemsSource="{Binding}">
        <ItemsControl.DataContext>
            <CollectionViewSource Source="{Binding DataContext.Artists, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"/>
        </ItemsControl.DataContext>
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <WrapPanel/>
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <!--<v:SingleArtistUC Artist="{Binding}" Background="{StaticResource color_bgelements}"/>-->
                <Grid Width="120" Margin="10" Background="{StaticResource color_bgelements}">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="120"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Button Command="{Binding DataContext.PlayArtistCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" CommandParameter="{Binding}" Grid.Column="1" Style="{StaticResource ArtistButtonImage}">
                        <ContentControl>
                            <Grid>
                                <Image Source="{Binding Image, Converter={StaticResource ImageByteConv}}" Height="120" Width="120" Stretch="UniformToFill"/>
                                <Image Source="..\Resources\Images\noimage.png" Stretch="UniformToFill" Style="{StaticResource ArtistButtonImageHover}"/>
                            </Grid>
                        </ContentControl>
                    </Button>

                    <!--<Image Source="..\Resources\Images\noimage.png" Height="120" Width="120" Grid.Row="0" Grid.Column="0" Stretch="UniformToFill"/>-->
                    <Grid Grid.Row="1">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="60"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <!--<TextBlock Text="{Binding Artist.ArtistName, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" TextWrapping="Wrap" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Grid.Column="0" Grid.Row="0" Margin="5" FontSize="12" TextAlignment="Center"/>-->
                        <!--<TextBlock Text="ik wil graag twee lijntjes tekst" TextWrapping="Wrap" VerticalAlignment="Top" HorizontalAlignment="Stretch" Grid.Column="0" Grid.Row="0" Margin="0,10,0,5" FontSize="12" TextAlignment="Center"/>-->

                        <Button Command="{Binding DataContext.ViewArtistDetailCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" CommandParameter="{Binding}" Background="{StaticResource color_bgbutton}" BorderBrush="Transparent" BorderThickness="0" VerticalAlignment="Top" HorizontalAlignment="Stretch" Margin="0,10,0,5" Grid.Row="0">
                            <Button.Template>
                                <ControlTemplate TargetType="Button">
                                    <ContentPresenter />
                                </ControlTemplate>
                            </Button.Template>
                            <TextBlock Text="{Binding ArtistName}" Style="{StaticResource TextInfo}" TextAlignment="Center"/>
                        </Button>
                        <!-- <Button Command="{Binding CMDPlayArtist, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" Tag="{Binding Artist.ID, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" Content="Play" Grid.Column="1" HorizontalAlignment="Stretch" Grid.Row="1" VerticalAlignment="Stretch" Margin="0,5,0,5" Style="{StaticResource TransButton}"/>-->
                    </Grid>
                </Grid>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>

这就是它应该一直保持的状态

当调整到错误的比率时情况如何


我会让它保持原样,它看起来很好。Windows 10中的Groove音乐看起来与我所知道的所有其他平铺环绕面板应用程序一样。用户可能会调整窗口大小以适应屏幕上更多/更少的瓷砖,因此调整瓷砖大小会很烦人。谢谢你的反馈,是的,我在设计方面很差劲,所以我实际上是从兴奋的玩家那里挑选颜色/格式。这只是我无聊的时候在业余时间做的一个项目。不管怎么说,我也在考虑调整瓷砖的尺寸,这会有点烦人。但我确实想去掉最后一列和滚动条之间的黑色条。有什么想法吗?我想没关系,我会离开的。也许看看Windows 10上的Groove音乐,它的右侧也有一个空白,然后也许你会感觉更好…我会保持原样,它看起来很好。Windows 10中的Groove音乐看起来与我所知道的所有其他平铺环绕面板应用程序一样。用户可能会调整窗口大小以适应屏幕上更多/更少的瓷砖,因此调整瓷砖大小会很烦人。谢谢你的反馈,是的,我在设计方面很差劲,所以我实际上是从兴奋的玩家那里挑选颜色/格式。这只是我无聊的时候在业余时间做的一个项目。不管怎么说,我也在考虑调整瓷砖的尺寸,这会有点烦人。但我确实想去掉最后一列和滚动条之间的黑色条。有什么想法吗?我想没关系,我会离开的。也许看看Windows 10上的Groove音乐,它的右侧也有一个空白,然后也许你会感觉更好。。。