wpf列表框行高

Jok*_*ini 3 c# wpf listbox

我已经在wpf中创建了一个列表框,并且在单击按钮时动态地将项添加到列表框中.我想知道如何将列表框中每行的总高度设置为特定值?

我在网上搜索并找到了类似的例子,但我不完全确定如何将这个解决方案整合到我的中.希望有人可以提供帮助.感谢你们.

如何设置WPF ListView行高?

<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>
Run Code Online (Sandbox Code Playgroud)

har*_*r07 10

应该与您找到的示例相同但使用listview非常相同.您只需要更改ListView...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>
Run Code Online (Sandbox Code Playgroud)