Dhaval Patel
Dhaval Patel

Reputation: 7601

Which Control is sutiable for creating a Dynamic Grid in WPF

Hello I am working on POS(Point of Sales) system in that I have to display the order in below mentioned image

enter image description here

I have tried with Wrap panel but it will generate the Grid like

enter image description here

see it will take maximum height for all grid I want to implement exactly same as image1 can anyone please help which WPF Control is suitable to fulfill it.

Upvotes: 1

Views: 228

Answers (1)

J.H.
J.H.

Reputation: 4322

The top picture looks like a wrap panel with vertical orientation to me.

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>

Upvotes: 1

Related Questions