在 WP7.5 应用程序中,我有一个包含网格的列表框。此网格包含两行和两列 (2x2)
在网格中,我显示文本框,我的问题是对齐不好!我不知道为什么,我设置了horizontalAligement = true,但没有改变!
这是我的代码:
<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>
这是我的结果:
这是我的课:
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();
}
}
任何人都可以帮助我吗?
非常感谢 :)
此致