WPF Desktop Application layout dilemma

880 views Asked by At

I want to develope my first real WPF Desktop Application. It's quite a lot of time since my last desktop application, which was developed with .NET 2.0 and Windows Forms. Since i have to develope a new Desktop Application, and i can take the advantage of .NET 4.0 i would really like to use WPF.

I am reading some online tutorial and documentation to choose the right way to do it, but i am a little lost with the new controls.

Basically i need a panel which show some textboxes and label above a datagrid. Do you think that i can achieve such a result with gridpanel control ? Thank you.

Sample

2

There are 2 answers

0
Luis Filipe On BEST ANSWER

In WPF you usually use several different controls. Control composition in WPF is a major feature and you'll gain a lot by knowing it and taking advantage of it.

When looking at your screen i divide it in two major parts: - campi di ricerca - resultati

For these two i'd use a Grid with two rows and one column. The ricerca area could use a DockPanel with the header aligned at the top and aother Grid With Fill contents.

... and so on, so on.

My best advice is for you to learn about WPF Composition

Hope i've helped a little bit

1
Csaba Fabian On

Yes, you need to use a Grid, with multiple rows and columns.

See the example on MSDN

        <Grid VerticalAlignment="Top" HorizontalAlignment="Left" ShowGridLines="True" Width="250" Height="100">
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>

            <TextBlock FontSize="20" FontWeight="Bold" Grid.ColumnSpan="3" Grid.Row="0">2005 Products Shipped</TextBlock>
            <TextBlock FontSize="12" FontWeight="Bold" Grid.Row="1" Grid.Column="0">Quarter 1</TextBlock>
            <TextBlock FontSize="12" FontWeight="Bold" Grid.Row="1" Grid.Column="1">Quarter 2</TextBlock>
            <TextBlock FontSize="12" FontWeight="Bold" Grid.Row="1" Grid.Column="2">Quarter 3</TextBlock>
            <TextBlock Grid.Row="2" Grid.Column="0">50000</TextBlock>
            <TextBlock Grid.Row="2" Grid.Column="1">100000</TextBlock>
            <TextBlock Grid.Row="2" Grid.Column="2">150000</TextBlock>
            <TextBlock FontSize="16" FontWeight="Bold" Grid.ColumnSpan="3" Grid.Row="3">Total Units: 300000</TextBlock>
        </Grid>