哪个Control适合在WPF中创建动态网格

时间:2015-04-16 16:11:35

标签: c# wpf wpf-controls

您好我正在研究POS(销售点)系统,因为我必须在下面提到的图像中显示订单

enter image description here

我尝试使用Wrap面板,但它会像

一样生成Grid

enter image description here

看到我想要实现与image1完全相同的所有网格的最大高度,任何人都可以帮助哪个WPF控件适合实现它。

1 个答案:

答案 0 :(得分:1)

顶部图片看起来像一个垂直方向的包装面板。

Screenshot

MainWindow.xaml

<Window x:Class="WpfApplication24.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Background="Black"
    Title="MainWindow" Height="350" Width="525">
<Window.Resources>
    <Style TargetType="TextBlock">
        <Setter Property="Margin" Value="5" />
        <Setter Property="Foreground" Value="Black" />
    </Style>
    <Style TargetType="StackPanel">
        <Setter Property="Width" Value="100" />
        <Setter Property="Margin" Value="5" />
        <Setter Property="Background" Value="Red" />
    </Style>
</Window.Resources>
<WrapPanel Orientation="Vertical">
    <StackPanel>
        <TextBlock Text="A Line" />
    </StackPanel>
    <StackPanel>
        <TextBlock Text="A Line" />
        <TextBlock Text="A Line" />
        <TextBlock Text="A Line" />
        <TextBlock Text="A Line" />
        <TextBlock Text="A Line" />
    </StackPanel>
    <StackPanel>
        <TextBlock Text="A Line" />
        <TextBlock Text="A Line" />
        <TextBlock Text="A Line" />
        <TextBlock Text="A Line" />
    </StackPanel>
    <StackPanel>
        <TextBlock Text="A Line" />
        <TextBlock Text="A Line" />
        <TextBlock Text="A Line" />
    </StackPanel>
    <StackPanel>
        <TextBlock Text="A Line" />
        <TextBlock Text="A Line" />
        <TextBlock Text="A Line" />
        <TextBlock Text="A Line" />
    </StackPanel>
    <StackPanel>
        <TextBlock Text="A Line" />
        <TextBlock Text="A Line" />
        <TextBlock Text="A Line" />
        <TextBlock Text="A Line" />
        <TextBlock Text="A Line" />
    </StackPanel>
    <StackPanel>
        <TextBlock Text="A Line" />
        <TextBlock Text="A Line" />
        <TextBlock Text="A Line" />
    </StackPanel>
    <StackPanel>
        <TextBlock Text="A Line" />
        <TextBlock Text="A Line" />
        <TextBlock Text="A Line" />
        <TextBlock Text="A Line" />
        <TextBlock Text="A Line" />
    </StackPanel>
</WrapPanel>