Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9167393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:22:47+00:00 2026-06-17T15:22:47+00:00

In a WP7.5 application, i have a listbox containing a grid. This grid contain

  • 0

In a WP7.5 application, i have a listbox containing a grid.
This grid contain two row, and two columns (2×2)

In grid, i display textbox, my problem is thar the alignement is bad ! I don’t know why, i set horizontalAligement=true, but no change !

Here is my code :

<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="Left">
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>

                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <TextBlock  HorizontalAlignment="Left" TextWrapping="Wrap" 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="Left" TextWrapping="Wrap" 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="Left" TextWrapping="Wrap" 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>

Here is my result :

enter image description here

Here is my Class :

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();
    }

}

Anyone could help me please ?

Thanks a lot 🙂

Best regards

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T15:22:48+00:00Added an answer on June 17, 2026 at 3:22 pm

    Your code is ok, problem is with the text trimming only.

    I used the same xaml in your question and did a sample.

    Case 1: First I took all the strings trimmed

    List<Myclass> list = new List<Myclass>();
    list.Add(new Myclass() { m_strCode = "001", m_strNom = "sample1", m_strFonction = "Fonction1" });
    list.Add(new Myclass() { m_strCode = "002", m_strNom = "sample2", m_strFonction = "Fonction2" });
    list.Add(new Myclass() { m_strCode = "003", m_strNom = "sample3 ", m_strFonction = "Fonction3" });
    list.Add(new Myclass() { m_strCode = "004", m_strNom = "sample4", m_strFonction = "Fonction4" });
    list.Add(new Myclass() { m_strCode = "005", m_strNom = "sample5", m_strFonction = "Fonction5" });
    ListBoxTiers.ItemsSource = list;
    

    And the result is : (Formated clearly as you expect)

    enter image description here

    Case 2: In this case, I took some strings with extraa spaces (observe sample1 and 004)

    List<Myclass> list = new List<Myclass>();
    list.Add(new Myclass() { m_strCode = "001", m_strNom = "    sample1", m_strFonction = "Fonction1" });
    list.Add(new Myclass() { m_strCode = "002", m_strNom = "sample2", m_strFonction = "Fonction2" });
    list.Add(new Myclass() { m_strCode = "003", m_strNom = "sample3 ", m_strFonction = "Fonction3" });
    list.Add(new Myclass() { m_strCode = "004    ", m_strNom = "sample4", m_strFonction = "Fonction4" });
    list.Add(new Myclass() { m_strCode = "005", m_strNom = "sample5", m_strFonction = "Fonction5" });
    ListBoxTiers.ItemsSource = list;
    

    And now the result is :

    enter image description here

    Hence, the problem is you are not properly trimming the text. Take care about that.

    Update:

    There you go. You don’t always call the constructor for instantiating the object. So, the better way is this.

        private string _m_strFonction;
        private string _m_strNom;
        private string _m_strCode;
    
        public string m_strCode
        {
            get { return _m_strCode; }
            set { _m_strCode = value.Trim(); }
        }
        public string m_strNom
        {
            get { return _m_strNom; }
            set { _m_strNom = value.Trim(); }
        }
        public string m_strFonction 
        { 
            get { return _m_strFonction; }
            set { _m_strFonction = value.Trim(); }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have seen this post: Display GIF in a WP7 application with Silverlight But
I have a user control in my wp7 application which contains two text boxes
I have a problem with Bing Maps control I use in my WP7 application.
I have two different pages in my WP7 Application, Page1 and Page2. On the
I have a problem with my WP7 application, it's working fine on the emulator
I have a application for WP7 and Android, and this application must have supporthas
I have a Listbox within my WP7 application, and inside the DataTemplate I have
I am developping a WP7 application. On the mainpage I have a ListBox. Each
I have the requirement in my WP7 application to display pushpins on a bing
I have listbox in my wp7 application. When An Item is Added into It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.