IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Windows Presentation Foundation Discussion :

WP7.5 - Problème d'alignement Grid !


Sujet :

Windows Presentation Foundation

  1. #1
    Membre du Club
    Inscrit en
    Avril 2007
    Messages
    281
    Détails du profil
    Informations forums :
    Inscription : Avril 2007
    Messages : 281
    Points : 47
    Points
    47
    Par défaut WP7.5 - Problème d'alignement Grid !
    Bonsoir à tous,


    Je suis entrain de développer une application pour WP7.5.

    Je possède une listbox qui contient par item, une grid de 2*2.

    Je possède un soucis d'alignement, j'ai cherché pendant des heures, et je ne trouve pas de solution.


    Voici une capture d'écran montrant mon soucis :



    Je précise que mes variables sont bien "trimmées".

    Voici maintenant mon XAML :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
     
    <ListBox x:Name="ListBoxTiers"  HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0">
    	<ListBox.ItemTemplate>
    		<DataTemplate>
     
    			<StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch" VerticalAlignment="Top" >
    				<Grid Margin="20" VerticalAlignment="Top" HorizontalAlignment="Stretch">
    					<Grid.RowDefinitions>
    						<RowDefinition />
    						<RowDefinition />
    					</Grid.RowDefinitions>
     
    					<Grid.ColumnDefinitions>
    						<ColumnDefinition />
    						<ColumnDefinition />
    					</Grid.ColumnDefinitions>
    					<TextBlock  HorizontalAlignment="Stretch"  Grid.Row="0" Grid.Column="0" Margin="0,0,10,0" x:Name="TxtBox_cCodeTiers" Text="{Binding m_strCode}" FontWeight="Bold" FontSize="22" />
    					<TextBlock  HorizontalAlignment="Stretch"  Grid.Row="0" Grid.Column="1" Margin="0,0,10,0" x:Name="TxtBox_cNomTiers" Text="{Binding m_strNom}"   FontWeight="Bold" FontSize="22" />
    					<TextBlock  HorizontalAlignment="Stretch"  Grid.Row="1" Grid.ColumnSpan="2" Grid.Column="0" Margin="0,0,10,0" x:Name="TxtBox_cCPostal" Text="{Binding m_strFonction}" />                                   
    				</Grid>
     
    			</StackPanel>
     
    		</DataTemplate>
    	</ListBox.ItemTemplate>
    </ListBox>
    Auriez vous une idée s'il vous plait ?

    Merci à tous


    Cordialement,

    Nixeus

  2. #2
    Membre expert
    Avatar de GuruuMeditation
    Homme Profil pro
    .Net Architect
    Inscrit en
    Octobre 2010
    Messages
    1 705
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Belgique

    Informations professionnelles :
    Activité : .Net Architect
    Secteur : Conseil

    Informations forums :
    Inscription : Octobre 2010
    Messages : 1 705
    Points : 3 568
    Points
    3 568
    Par défaut
    Et si tu mets HorizontalAlignment="Left" ?

    Sinon un outil indispensable pour XAML : XAMLSpy http://xamlspy.com/
    Microsoft MVP : Windows Platform

    MCPD - Windows Phone Developer
    MCPD - Windows Developer 4

    http://www.guruumeditation.net

    “If debugging is the process of removing bugs, then programming must be the process of putting them in.”
    (Edsger W. Dijkstra)

  3. #3
    Membre habitué
    Profil pro
    Consultant informatique
    Inscrit en
    Septembre 2009
    Messages
    99
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Consultant informatique

    Informations forums :
    Inscription : Septembre 2009
    Messages : 99
    Points : 152
    Points
    152
    Par défaut
    Idem, un HorizontalAlignment="Left" sur ton 2eme TextBlock devrait regler le problème. Sinon, à quoi te sers le StackPanel dans ton cas ? J'ai dû mal à comprendre pourquoi il existe.
    Cette réponse vous a aidé ?
    Problème résolu ?

  4. #4
    Membre du Club
    Inscrit en
    Avril 2007
    Messages
    281
    Détails du profil
    Informations forums :
    Inscription : Avril 2007
    Messages : 281
    Points : 47
    Points
    47
    Par défaut
    Bonsoir

    Merci pour vos réponses.
    J'ai déjà tenté l'alignement horizontal à LEFT, cela n'y change malheureusement rien

    Cela fait déjà plusieurs jours que je planche, je ne trouve pas d'où cela vient.

    Pour le stackpanel, je ne sais pas, je suis débutant en XAML WPF et je l'avais mis je ne sais plus pourquoi.

    D'autres idées ?

    Merciii

  5. #5
    Membre habitué
    Profil pro
    Consultant informatique
    Inscrit en
    Septembre 2009
    Messages
    99
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Consultant informatique

    Informations forums :
    Inscription : Septembre 2009
    Messages : 99
    Points : 152
    Points
    152
    Par défaut
    Mettre ta première colonne en largeur automatique ?

    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    <Grid.ColumnDefinitions>
    	<ColumnDefinition Width="Auto" />
    	<ColumnDefinition />
    </Grid.ColumnDefinitions>
    Cette réponse vous a aidé ?
    Problème résolu ?

  6. #6
    Membre du Club
    Inscrit en
    Avril 2007
    Messages
    281
    Détails du profil
    Informations forums :
    Inscription : Avril 2007
    Messages : 281
    Points : 47
    Points
    47
    Par défaut
    Après différents tests, c'est un problem de trimming ! Néanmoins, ce que je ne comprends pas, c'est qu'en débug je ne vois pas d'espaces.

    Par ailleurs ma classe que j'affiche dans la listbox possède bien des .trim() au niveau des variables.

    C'est un problème de trimming mais c'est très étrange

    Voici le code de ma classe CTiers:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
     
      public class CTiers
        {
            public enum TypeTiers { Client, Fournisseur, Contact, Collaborateur, Commercial, Prospect};
     
            TypeTiers m_TypeTiers { set; get; }
     
            public string m_strTypeTiers { get; set; }
            public string m_strCode    { set; get; }
            public string m_strNom { set; get; }
            public string m_strPrenom { set; get; }
            public string m_strTel { set; get; }
            public string m_strGsm { set; get; }
            public string m_strFax { set; get; }
            public string m_strMail { set; get; }
            public string m_strWebSite { set; get; }
            public string m_strVille { set; get; }
            public string m_strCpostal { set; get; }
            public string m_strRue { set; get; }
            public string m_strFonction { set; get; }
     
            public CTiers()
            {
     
            }
     
            public CTiers(TypeTiers oTypeTiers, string strCode, string strNom, string strPrenom, string strTel, string strGsm, string strFax, string strRue,string strVille,string strCPostal,string strMail,string strWebSite,string strFonction)
            {
                m_TypeTiers = oTypeTiers;
                m_strCode = strCode.Trim();
                m_strNom = strNom.Trim();
                m_strPrenom = strPrenom.Trim();
                m_strVille = strVille.Trim();
                m_strTel = strTel.Trim();
                m_strGsm = strGsm.Trim();
                m_strFax = strFax.Trim();
                m_strWebSite = strWebSite.Trim();
                m_strRue = strRue.Trim();
                m_strMail = strMail.Trim();
                m_strCpostal = strCPostal.Trim();
                m_strTypeTiers = oTypeTiers.ToString().Trim();
                m_strFonction = strFonction.Trim();
            }
     
        }

Discussions similaires

  1. [CSS] Problème d'alignement des images
    Par Walabar dans le forum Mise en page CSS
    Réponses: 2
    Dernier message: 04/08/2006, 15h42
  2. débutant, problème d'alignement...
    Par celmakie dans le forum Général JavaScript
    Réponses: 1
    Dernier message: 01/04/2006, 21h13
  3. problème d'alignement swing
    Par demonia dans le forum AWT/Swing
    Réponses: 2
    Dernier message: 19/02/2006, 21h47
  4. Réponses: 1
    Dernier message: 22/12/2005, 11h23
  5. Problème d'alignement
    Par zorely dans le forum Mise en forme
    Réponses: 4
    Dernier message: 09/08/2005, 10h52

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo