Précédent   Forum du club des développeurs et IT Pro > Dotnet > Développement Windows > Windows Presentation Foundation
Windows Presentation Foundation Forum d'entraide sur le développement d'applications Windows avec Windows Presentation Foundation
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 23/12/2012, 23h29   #1
Nixeus
Futur Membre du Club
 
Inscription : avril 2007
Messages : 245
Détails du profil
Informations forums :
Inscription : avril 2007
Messages : 245
Points : 17
Points : 17
Par défaut Choix de composant (StackPanel, WrapPanel, Grid..)

Bonsoir à tous,

Je suis débutant en XAML/WPF.

J'ai lu différents tuto afin de comprendre les différents composant comme les StackPanel, WrapPanele,etc...

Je suis entrain de concevoir une application affichant une ListBox, avec deux lignes par "item".

Sur chaque ligne serait affichés plusieurs variables.

Voici a quoi pourrait ressembler mon application:



Au niveau de mon item, je ne sais pas trop quoi choisir.

Un stackPanel affichant des TextBlock?
Un wrapPanel ?
Une grid avec des colonnes ?

Quelqu'un pourrait m'orienter dans le choix ?

Et éventuellement je ne serai pas contre un peu de code pour m'aider à commencer

Merci à tous,

Cordialement,

Nixeus
Nixeus est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 27/12/2012, 16h54   #2
Lordinaire
Membre habitué
 
Maxime FRAPPAT
Consultant informatique
Inscription : septembre 2009
Messages : 99
Détails du profil
Informations personnelles :
Nom : Maxime FRAPPAT
Localisation : France

Informations professionnelles :
Activité : Consultant informatique

Informations forums :
Inscription : septembre 2009
Messages : 99
Points : 149
Points : 149
Salut,

Voici une solution parmi tant d'autres :

Code xml :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 
<ListBox>
    <ListBox.ItemTemplate>
        <DataTemplate>
            <StackPanel Orientation="Vertical">
                <!-- 1ere ligne -->
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="Variable1" />
                    <TextBlock Text="Variable2" />
                </StackPanel>
                <!-- 2eme ligne -->
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="Variable3" />
                    <TextBlock Text="Variable4" />
                </StackPanel>
            </StackPanel>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

La question qui peut te faire choisir la bonne solution serait :
- Le placement de tes champs à l'intérieur d'un item est-il complexe (remplissage de toute la zone, alignement, etc...) ?

S'il est simple préfère le StackPanel, dans le cas contraire tu sera peut-être obliger de te tourner vers la Grid.
Lordinaire est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 05h40.


 
 
 
 
Partenaires

Hébergement Web