3

I've created a listbox in wpf and I'm adding items to the listbox dynamically upon a button be clicked. I was wondering how I can set the overall height for each row in the listbox to a specific value?

I've search around online and found this similar example but I'm not entirely sure how to integrate this solution into mine. Hopefully someone can help. Thank you guys.

How to set WPF ListView row height?

<Window x:Class="stadio.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Stadio" Height="350" Width="525" Background="#FF212121">
    <Grid>
        <ListBox x:Name="uiFileList" BorderThickness="0" Background="{x:Null}" Foreground="Gainsboro" Margin="6"/>

    </Grid>
</Window>
Community
  • 1
  • 1
JokerMartini
  • 5,674
  • 9
  • 83
  • 193

1 Answers1

12

Should be very identical to the example you found which demonstrate the same but using listview. You only need to change ListView... to ListBox... :

<ListBox x:Name="uiFileList" BorderThickness="0" 
         Background="{x:Null}" Foreground="Gainsboro" 
         Margin="6">
    <ListBox.ItemContainerStyle>
        <Style TargetType="ListBoxItem">
            <Setter Property="Height" Value="50" />
        </Style>
    </ListBox.ItemContainerStyle>
</ListBox>
har07
  • 88,338
  • 12
  • 84
  • 137