的Xaml
<ListBox x:Name="List" Margin="8,8,8,8">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical" Width="Auto" Height="300">
<TextBlock x:Name="tbName" Width="Auto" FontSize="22" FontWeight="Bold" Text="{Binding Name}" />
<TextBlock x:Name="tbEmail" Width="Auto" FontSize="22" Height="Auto" Text="{Binding Amount}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
<Button Content="Button" Height="89" Click="Button_Click_2" Width="138"/>
</ListBox>
C#
foreach (var item in Expense)
{
Display data = new Display();
data.Name = item.Account_Name;
data.Amount = item.Total;
this.List.Items.Add(data);
}
虽然上面的代码在windows phone中执行,但我得到一个名称和数量在两个不同行的列表框。 我该怎么办,让它们显示在同一行,(左边的名字和右边的数字)??
答案 0 :(得分:0)
Stackpanel
需要水平方向
<StackPanel Orientation="Horizontal" Width="Auto" Height="300">
<TextBlock x:Name="tbName" Width="Auto" FontSize="22" FontWeight="Bold" Text="{Binding Name}" />
<TextBlock x:Name="tbEmail" Width="Auto" FontSize="22" Height="Auto" Text="{Binding Amount}"/>
</StackPanel>