2016-06-29 15 views
8

どのようにWindows 10 UWPアプリケーションでListViewコントロールの項目の高さを変更しますか?あなたはまたに必要UWP変更リストビューアイテムの高さ

 <ListView x:Name="listView" IsItemClickEnabled="True"> 
      <ListView.ItemContainerStyle> 
       <Style TargetType="ListViewItem"> 
        <Setter Property="Height" Value="20" /> 
       </Style> 
      </ListView.ItemContainerStyle> 

      <ListView.ItemTemplate> 
       <DataTemplate> 
        <StackPanel Height="20"> 
         <TextBlock Text="{Binding Title}" TextWrapping="NoWrap" Foreground="White" Height="20"/> 
        </StackPanel> 
       </DataTemplate> 
      </ListView.ItemTemplate> 
     </ListView> 

答えて

11

UWPの例では、次の行の高さ20を(WPFの質問がこれを提案するかもしれないが、UWP XAMLで動作するようには思えない)ことはありません。 MinHeightプロパティを設定します。

​​
0

データテンプレートのスタイルを上書きすることもできます。

<Page.Resources> 
    <ResourceDictionary> 
     <ResourceDictionary.ThemeDictionaries> 
      <ResourceDictionary x:Key="Default"> 
       <x:Double x:Key="ListViewItemMinHeight">20</x:Double> 
       <x:Double x:Key="ListViewItemHeight">20</x:Double> 
      </ResourceDictionary> 
      <ResourceDictionary x:Key="HighContrast"> 
      </ResourceDictionary> 
     </ResourceDictionary.ThemeDictionaries> 
    </ResourceDictionary> 
</Page.Resources> 

http://loekvandenouweland.com/content/UWP-lightweight-listview-styling.html

関連する問題