我正在尝试在我的视图中设置项目列表,如下所示:
但问题是我得到了这个:
这是我的代码:
<Grid Background="#e6e7e8" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid Background="#6b6b69" VerticalAlignment="Top" Grid.Column="0" Grid.Row="0">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" >
<Border Grid.Column="0" Height="39" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Image Source="images/cuisineBlanc.png" />
</Border>
<Border Grid.Column="0" Height="39" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="134">
<TextBlock Text="Cuisines" Foreground="White"/>
</Border>
</StackPanel>
</Grid>
<Grid x:Name="Grid1" Grid.Column="0" Grid.Row="1" VerticalAlignment="Top" >
<ListView x:Name="listme">
<ListView.ItemTemplate >
<DataTemplate>
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Grid.Column="0" Grid.Row="0">
<Image Margin="2" Height="35" Source="images/0.png"/>
<StackPanel Orientation="Horizontal" >
<TextBlock Text="Cuisine" Foreground="#575855" FontSize="25" Margin="5" />
<TextBlock Text="{Binding Path=nom}" Foreground="#575855" FontSize="25" Margin="2,5,5,5" />
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Column="1" Grid.Row="0">
<Image Source="images/click.png"/>
</StackPanel>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</Grid>
如何在每个listview项目中设置边框粗细,将click.png项目放在Left.Can你帮我请修改我的视图就像原来的一样 谢谢你的帮助:
答案 0 :(得分:2)
我已经测试了您的示例并且显示正确:
<ListView x:Name="listView">
<ListView.ItemTemplate >
<DataTemplate>
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Grid.Column="0" Grid.Row="0">
<Image Margin="2" Height="30" Width="30" Source="{StaticResource ProjectIcon}"/>
<StackPanel Orientation="Horizontal" >
<TextBlock Text="Cuisine" Foreground="#575855" FontSize="25" Margin="5" />
<TextBlock Text="{Binding Path=nom}" Foreground="#575855" FontSize="25" Margin="2,5,5,5" />
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Column="1" Grid.Row="0">
<Image Source="{StaticResource ProjectIcon}" Height="30" Width="30"/>
</StackPanel>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>