我是UWP的新手,并且在一天中的大部分时间都在努力应该是一些简单的XAML,但我无法按照我想要的方式进行布局.我想要实现的目标如下所示.
在第1列中水平和垂直居中的单个文本.在第2列中左对齐的2个文本.在第3列中水平和垂直居中的单个文本.
这是我到目前为止的XAML.我知道我需要使用列,但即使在尝试这样做时,我根本无法获得正确的布局.
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TramTimes"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Class="TramTimes.ServicesPage"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<ListView x:Name="list" IsItemClickEnabled="False" SelectionMode="None">
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<StackPanel>
<TextBlock Text="{Binding Destination}"/>
<TextBlock Text="{Binding Company}"/>
</StackPanel>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</Page>
Run Code Online (Sandbox Code Playgroud)
感谢任何帮助,使列表看起来像我需要的方式.
编辑
这是我现在使用的代码和我得到的结果 - 任何人都可以帮助我让网格填满整个列表的宽度?
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TramTimes"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:Maps="using:Windows.UI.Xaml.Controls.Maps"
x:Class="TramTimes.ServicesPage"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Maps:MapControl x:Name="map" Height="300" VerticalAlignment="Top"/>
<ListView x:Name="list" IsItemClickEnabled="False" Margin="0,300,0,0" SelectionMode="None">
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="3.5*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Binding Scheduled}"/>
<StackPanel Grid.Column="2"> …Run Code Online (Sandbox Code Playgroud)