XAML GridView控件项目
问题描述:
我有这样的GridView之间移除空间,XAML GridView控件项目
而且要项目,我尝试设置Marging和填充之间移除空间为0,因为这:
<GridView ItemsSource="{Binding ElementName=AprehenderPage,Path=DataContext.LecturasCorrectas}"
Margin="0"
Padding="0">
<GridView.ItemTemplate>
<DataTemplate>
<Grid Height="35"
Margin="0"
Padding="0">
<Image Source="{Binding Imagen}"
Margin="0"/>
</Grid>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
但这什么都不做。
我该如何去除这些空间?
或
要使用哪些其他控件?
答
尝试自动调高。
<Grid Height="Auto" ...
你也可以有消极的利润率如果需要的话
和利润如..
Margin ="-value"
答
它看起来像你可能会使用UWP而不是WPF,因为我不认为WPF GridView有一个ItemsSource。如果是这样的话,那么你的利润率大概是从GridViewItem:
GridViewItem(容器对象)根据MSDN有边距:
https://msdn.microsoft.com/en-us/library/windows/apps/mt299127.aspx
所以你需要再整项,如下所示:
<Style x:Key="MyItem" TargetType="GridViewItem">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Margin" Value="0"/>
<Setter Property="Padding" Value="0"/>
</Style>
并有集装箱的风格在你的GridView二传手:
<Setter Property="ItemContainerStyle" Value="{StaticResource MyItem}" />
+0
这听起来不错,我会试试看。 –
我必须在哪里放置它?在项目模板?或在网格定义? –
已更新我的答案尝试用模板内的自动高度,然后相应地工作 – afr0
什么都没有,因为我需要,没有任何负边缘,它会产生一个奇怪的项目之间的覆盖。 –