How do I Style ListView Items?

前端 未结 1 1598
清歌不尽
清歌不尽 2021-01-04 18:55

I have a ListView that is data bound and I want to alter the font properties for each item. I\'m not having much luck finding the appropriate properties. The

相关标签:
1条回答
  • 2021-01-04 19:29

    You can set the ItemContainerStyle:

    <ListView ItemsSource="{Binding Updates}">
        <ListView.View>
            <GridView>
                <GridViewColumn DisplayMemberBinding="{Binding TimeStamp}" Header="TimeStamp" />
                <GridViewColumn DisplayMemberBinding="{Binding UpdateData}" />
            </GridView>
        </ListView.View>
        <ListView.ItemContainerStyle>
            <Style TargetType="ListViewItem">
                <Setter Property="FontSize" Value="14" />
                <Setter Property="Foreground" Value="Blue" />
                <Setter Property="FontWeight" Value="Bold" />
                <Setter Property="FontStyle" Value="Italic" />
            </Style>
        </ListView.ItemContainerStyle>
    </ListView>
    

    Note that it will apply to the items of the ListView, not the ListView itself (e.g. the column headers won't be affected). If you want to apply those properties to the whole ListView, you can set them directly on the ListView:

    <ListView ItemsSource="{Binding Updates}"
              Foreground="Blue" FontSize="14" ...>
    
    0 讨论(0)
提交回复
热议问题