2

I would like to create UniformGrid which will contain WindowsFormsHosts(inside them are WinForms). 4 Hosts in every row(4 cols) and after exceding its' visible capacity new elements will be added underneath and user will be able to scroll the UniformGrid. I do not know even where to start beside defining UniFormGrid and its' column number.

 <UniformGrid x:Name="Grid"  Columns="4">

    </UniformGrid>

The behaviour I would like to get is just like in Windows' explorer if there are too many icons in the view you can scroll down.

I used UniformGrid because I needed equivalent of GridLayout() in Java. I want every added element to be the same size. I add elements from .cs.

4

1 回答 1

2

我只是从评论中扩展它,这取决于您的WinForm控件的大小,并且取决于您想要的调整大小行为是什么,您可以简单地将 a 包装WrapPanel在 a 中ScrollViewer,例如:

    <ScrollViewer>
        <WrapPanel>
            <Grid Width="100" Height="100" Background="Red"/>
            <Grid Width="100" Height="100" Background="Blue"/>
            <Grid Width="100" Height="100" Background="Yellow"/>
            <Grid Width="100" Height="100" Background="Red"/>
            <Grid Width="100" Height="100" Background="Blue"/>
            <Grid Width="100" Height="100" Background="Yellow"/>
            <Grid Width="100" Height="100" Background="Red"/>
            <Grid Width="100" Height="100" Background="Blue"/>
            <Grid Width="100" Height="100" Background="Yellow"/>
        </WrapPanel>
    </ScrollViewer>

在此处输入图像描述

为了获得更大的灵活性,此答案链接到提供 的项目,UniformWrapPanel值得一看。

于 2014-01-05T01:09:21.473 回答