c# - WPF:ListBox 项目从下到上显示

标签 c# wpf listbox

我觉得标题不清楚 我正在使用 WPF 并创建自定义消息控件。我有 message User Control 和显示在 custom Messages control[ListBox] 中的消息用户控件。 XAML 代码:

 <ListBox x:Name="uiMessages" ItemsSource="{Binding Path=Messages}">
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapPanel Orientation="Horizontal" IsItemsHost="True" />
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <wpfMessages:MessageDisplay>

                    </wpfMessages:MessageDisplay>
                </DataTemplate>
            </ListBox.ItemTemplate>
</ListBox>

当前 View :

enter image description here

预期:

enter image description here

现在列表框项目从上到下显示,红色消息后有空白区域。如果 2 条绿色消息在底部,红色消息在顶部,我会很好。预期是从 botton 到 top 添加消息,而不是像现在这样从 top 到 botton。 enter image description here

有什么想法吗?

在此先感谢 Jamaxack!

最佳答案

有点不清楚,但我认为您想更改 ItemsPanel 布局。

<ListBox.ItemsPanel>
    <ItemsPanelTemplate>
        <VirtualizingStackPanel VerticalAlignment="Bottom"/>
    </ItemsPanelTemplate>
</ListBox.ItemsPanel>

关于c# - WPF:ListBox 项目从下到上显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27956390/

相关文章:

php - 如何在 php(Laravel) 中使用动态列表框

wpf - ListBox.ItemTemplate 中的数据绑定(bind)用户控件

c# - 无法从 XML (web.config) 获取两个连接字符串

c# - 如何通过C#客户端将当前SQL Server用户保存到自定义表中?

c# - 用于无损 Exif 重写的 .NET C# 库?

c# - 我可以通过剪贴板将 [Serializable] 对象传递到 Excel 加载项吗?

c# - 如何在 WPF 图像控件中偏移图像的起点(平移图像)

c# - WPF。在没有 ItemsSource 的 ListBox 中对项目进行分组

c# - Thread.Abort() 导致应用程序被杀死

wpf - Window.Show() 显示新窗口然后消失在主窗口后面