C# 列表框中的包装,带有水平和;垂直滚动

C# 列表框中的包装,带有水平和;垂直滚动,c#,.net,wpf,vb.net,xaml,C#,.net,Wpf,Vb.net,Xaml,根据,我使用以下代码: <ListBox ScrollViewer.HorizontalScrollBarVisibility="Disabled"> <ListBox.ItemsPanel> <ItemsPanelTemplate> <WrapPanel HorizontalAlignment="Center" VerticalAlignment="Center" /> </I

根据,我使用以下代码:

<ListBox ScrollViewer.HorizontalScrollBarVisibility="Disabled">
    <ListBox.ItemsPanel>
        <ItemsPanelTemplate>
            <WrapPanel HorizontalAlignment="Center" VerticalAlignment="Center" />
        </ItemsPanelTemplate>
    </ListBox.ItemsPanel>
    <Image Source="http://placehold.it/50x50" Stretch="None"/>
    <Image Source="http://placehold.it/60x50" Stretch="None"/>
    <Image Source="http://placehold.it/70x50" Stretch="None"/>
    <Image Source="http://placehold.it/80x50" Stretch="None"/>
    <Image Source="http://placehold.it/90x50" Stretch="None"/>
    <Image Source="http://placehold.it/100x50" Stretch="None"/>
    <Image Source="http://placehold.it/600x200" Stretch="None"/>
</ListBox>

这就是它的样子:

我需要有水平和垂直滚动条,就像这样(只是一个使用HTML的快速模型):


使用
ScrollViewer.HorizontalScrollBarVisibility=“Disabled”
使图像环绕,但禁用了水平滚动条,这就是为什么我看不到
600x200
图像的其余部分

我费了好几个小时才修好,但运气不好,能不能请一些人帮我

列表框中的图像使用不同于用户输入的尺寸进行更新。

添加边距:

<ListBox>
<ListBox.ItemsPanel>
    <ItemsPanelTemplate>
        <WrapPanel MaxWidth="600" HorizontalAlignment="Center" VerticalAlignment="Center" />
    </ItemsPanelTemplate>
</ListBox.ItemsPanel>
<Image Margin ="5" Source="http://placehold.it/50x50" Stretch="None"/>
<Image Margin ="5" Source="http://placehold.it/60x50" Stretch="None"/>
<Image Margin ="5" Source="http://placehold.it/70x50" Stretch="None"/>
<Image Margin ="5" Source="http://placehold.it/80x50" Stretch="None"/>
<Image Margin ="5" Source="http://placehold.it/90x50" Stretch="None"/>
<Image Margin ="5" Source="http://placehold.it/100x50" Stretch="None"/>
<Image Margin ="5" Source="http://placehold.it/600x200" Stretch="None"/>
</ListBox>


也许你需要一个小于5的余量;试试看。也可能是600的其他值。

ScrollViewer.HorizontalScrollBarVisibility=“Disabled”在WPF应用程序中禁用滚动,而不是IEI在XAML中进行了更改。这有用吗?至少现在显示了滚动条。删除了Scollbar禁用代码并添加了MaxWidth设置。非常感谢。我添加了后端代码来设置
MaxWidth
,现在它工作得非常完美。再次感谢!