How to change font size for a Universal ListView Windows app

I am working on a Universal Windows App and am currently working on a Windows Phone part of it. I have a ListView control on one of the pages and I have added several items to it programmatically. However, I cannot work out how to increase the font size of the items in the ListView. I tried to change the font size, but it doesn't matter, the text size in the ListView is tiny. Here is the current XAML.

<ListView x:Name="listView" HorizontalAlignment="Left" Height="434" Margin="0,10,0,0" VerticalAlignment="Top" Width="352" FontSize="24"/>

      

Any idea what I am doing wrong? I suspect there is some pattern or something that I need to use, or it overwrites the font size in XAML, but I am struggling to find documentation on what this might be. This is a pretty simple thing I want to do.

+3


source to share


4 answers


In theory your code should work, but if you don't see what you want, I might suspect you might have some kind of internal component that overrides your font size property. This way you don't see any errors, but you never get what you expect. Look at the internal components for example. <ListView.ItemTemplate>

fromTextBlock

If it doesn't solve your problem, check in App.xaml for something that overrides this property like this



<Style TargetType="TextBlock">
      <Setter Property="FontSize" Value="40" /> 
</Style>

      

to make it work i suggest you add property TextElement.FontSize="24"

to list

+2


source


I had the same problem with items in my listView. You can do it:



<ListView x:Name="listView" HorizontalAlignment="Left" Height="434" Margin="0,10,0,0" VerticalAlignment="Top" Width="352" FontSize="24">
    <ListView.ItemTemplate>
        <DataTemplate>
            <StackPanel Margin="0,0,0,27.5">
                <TextBlock FontSize="20" Text="Your List View Item"/>
            </StackPanel>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

      

0


source


Add this to your xaml code and it should work:

  <Style TargetType="ListViewItem">
              <Setter Property="FontSize" Value="20"/>
  </Style>

      

0


source


Here's my XAML to set the font size and text color of ListView items.

    <ListView x:Name="daysInfoListView" HorizontalAlignment="Left" Height="113" Margin="10,193,0,0" VerticalAlignment="Top" Width="480" Foreground="#FF0000CC" Background="#FFCC0000" FontSize="12" IsTabStop="False" Grid.ColumnSpan="2">
        <ListView.ItemContainerStyle>
            <Style TargetType="ListViewItem">
                <Setter Property="Foreground" Value="#FF0000CC"></Setter>
                <Setter Property="FontSize" Value="12"></Setter>
            </Style>
        </ListView.ItemContainerStyle>
    </ListView>

      

0


source







All Articles