我有一个 ListView,我想让 ListItems 左侧显示图像,右侧显示文本和第二个文本。我尝试过使用 Grid 和 DockPanel 的不同方法,但例如 DockPanel 无法填满整个宽度。
<Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="45"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Text="Topliste gesamt" FontSize="16" Margin="10"/>
<Grid Background="White" Margin="5" Grid.Row="1">
<Border BorderBrush="#25202D" BorderThickness="1" Padding="3" VerticalAlignment="Stretch">
<Border.Background>
<ImageBrush ImageSource="Assets/HHLogoBack.png" Stretch="Uniform" />
</Border.Background>
<ListView ItemsSource="{Binding TopOverall}" Margin="10" HorizontalAlignment="Stretch">
<ListView.ItemTemplate>
<DataTemplate>
<DockPanel HorizontalAlignment="Stretch" Background="Beige" LastChildFill="True">
<Image Source="{Binding Avatar}" DockPanel.Dock="Left" Width="30" HorizontalAlignment="Center"/>
<TextBlock Text="{Binding PlayerObj.Name}" Foreground="Black" Margin="10,0,0,0"/>
<TextBlock Text="{Binding Points}" DockPanel.Dock="Right" Foreground="Black" VerticalAlignment="Center" Margin="10,0,0,0" />
</DockPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Border>
</Grid>
</Grid>
有什么提示吗,我错在哪里?
HorizontalAlignment="Right"
XAML:
输出:
希望有帮助。