2016-06-25 3 views
1

UWP 10에서 ListView을 가로로 늘리고 싶습니다. HorizontalContentAlignmentStretch으로 설정합니다. 그것은 다소 효과가 있지만, 정확히 내가 원하는 결과는 아닙니다.ListViewItem 가로 스트레칭 UWP 10

ListView 배경을 Aqua로 설정 했으므로 ListView 자체가 100 %로 확대됩니다. 콘텐츠도 스트리 칭이지만 왼쪽과 오른쪽에이 공간이 있습니다.

제 질문은 : 어떻게 그 여백을 왼쪽과 오른쪽으로 제거 할 수 있습니까? XAML 여기

Screenshot

그리고있다 :

<ListView.ItemContainerStyle> 
    <Style TargetType="ListViewItem"> 
     <Setter Property="HorizontalContentAlignment" Value="Stretch"/> 
     <Setter Property="Margin" Value="0"/> 
     <Setter Property="Padding" Value="0"/> 
    </Style> 
</ListView.ItemContainerStyle> 

당신에게 : 당신은 ItemContainerStyle의 패딩과 마진을 수정해야

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> 
    <Grid> 
     <Grid.RowDefinitions> 
      <RowDefinition Height="Auto" /> 
      <RowDefinition Height="*" /> 
     </Grid.RowDefinitions> 
     <AutoSuggestBox x:Name="SalonSearchBox" 
         Grid.Row="0" 
         QueryIcon="Find" 
         PlaceholderText="Suchen..." 
         Margin="8" /> 
     <ListView x:Name="SalonsListView" 
        Grid.Row="1" 
        Background="Aqua" 
        ItemsSource="{x:Bind ViewModel.Salons, Mode=OneWay}" 
        HorizontalAlignment="Stretch" 
        Margin="0"> 
      <ListView.ItemContainerStyle> 
       <Style TargetType="ListViewItem"> 
        <Setter Property="HorizontalContentAlignment" 
          Value="Stretch" /> 
       </Style> 
      </ListView.ItemContainerStyle> 
      <ListView.ItemTemplate> 
       <DataTemplate x:DataType="salon:Salon"> 
        <Grid Height="110" 
          Padding="8"> 
         <Grid.RowDefinitions> 
          <RowDefinition Height="*" /> 
          <RowDefinition Height="Auto" /> 
          <RowDefinition Height="Auto" /> 
          <RowDefinition Height="Auto" /> 
         </Grid.RowDefinitions> 
         <Grid.Background> 
          <ImageBrush ImageSource="{x:Bind ListingImage}" 
             Stretch="UniformToFill" /> 
         </Grid.Background> 

         <TextBlock x:Name="TitleTextBlock" 
            Grid.Row="1" 
            Text="{x:Bind Name}" 
            FontSize="20" 
            Foreground="White" 
            FontWeight="SemiBold" /> 
         <TextBlock x:Name="LocationTextBlock" 
            Grid.Row="2" 
            Foreground="White" 
            FontWeight="SemiLight"> 
          <Run Text="{x:Bind Place.PLZ}" /> 
          <Run Text="{x:Bind Place.Address}" /> 
         </TextBlock> 
         <TextBlock x:Name="DescriptionTextBlock" 
            FontWeight="SemiLight" 
            Grid.Row="3" 
            x:Phase="1" 
            Text="{x:Bind Info}" 
            Foreground="Gray" /> 
        </Grid> 
       </DataTemplate> 
      </ListView.ItemTemplate> 
     </ListView> 
    </Grid> 
</Grid> 

답변

1

여기

은 결과입니다 또한 정의했다 그리드의을 8로 패딩하면 아이템 주위에 아쿠아 배경이 생깁니다.

+0

대단히 감사합니다! 그리드의 패딩이 없으면 텍스트가 가장자리에 붙습니다. 그리드의 패딩과도 작동합니다. – DanyX23