添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Describe the bug

Background of ListViewItemPresenter rendered with additional spaces. However, content uses the entire area of the presenter.

Reproduced on WindowsAppSDK 1.0.0. Normal on 0.8. *

Steps to reproduce the bug

Xaml:

<Grid Background="LightGray">
   <ListView SelectionMode="None">
      <ListView.ItemContainerStyle>
         <Style TargetType="ListViewItem">
            <Setter Property="BorderBrush" Value="Black" />
            <Setter Property="BorderThickness" Value="0, 0, 0, 1" />
            <Setter Property="Background" Value="DimGray" />
            <Setter Property="Template">
               <Setter.Value>
                  <ControlTemplate TargetType="ListViewItem">
                     <ListViewItemPresenter Background="{TemplateBinding Background}"
                                            BorderBrush="{TemplateBinding BorderBrush}"
                                            BorderThickness="{TemplateBinding BorderThickness}" />
                  </ControlTemplate>
               </Setter.Value>
            </Setter>
         </Style>
      </ListView.ItemContainerStyle>
      <ListView.ItemTemplate>
         <DataTemplate>
            <Border>
               <TextBlock Text="{Binding}" />
            </Border>
         </DataTemplate>
      </ListView.ItemTemplate>
      <x:String>11111</x:String>
      <x:String>22222</x:String>
      <x:String>33333</x:String>
      <x:String>44444</x:String>
      <x:String>55555</x:String>
   </ListView>
</Grid>

Expected behavior

If set background directly to DataTemplate:

<ListView.ItemTemplate>
   <DataTemplate>
      <Border Background="DimGray">
         <TextBlock Text="{Binding}" />
      </Border>
   </DataTemplate>
</ListView.ItemTemplate>

Screenshots

No response

NuGet package version

No response

Windows app type

  • Win32
  • Device form factor

    Desktop

    Windows version

    May 2020 Update (19041), May 2019 Update (18362)

    Additional context

    No response

    Felix-CodingClimber, AlexLonberg, Slion, and sbaeumlisberger reacted with thumbs up emoji Slion reacted with confused emoji tylersouthard and Slion reacted with eyes emoji All reactions

    @StephenLPeters

    I filed https://stackoverflow.com/questions/74221139/remove-listviewitempresenter-border-in-microsoft-ui-xaml-listview before finding this bug report.

    As reported there, there appears to be an additional Border element as a child of the ListViewItemPresenter, and it has a Margin of 4,2,4,2.

    I'm very interested in knowing if there's a way to remove this margin, since it has caused our dozens and dozens of ListViews to render improperly.

    No workaround and no fix for nearly 3 years? This is what’s been holding me back from updating my app’s Microsoft.UI.Xaml package. Setting MinHeight (on the DataTemplate, ListViewItem, and ListViewItemPresenter) did nothing for me.

    There’s really no workaround/solution? My app is UWP so applies to both app types.