我有一个名为 MessagesCollection 的集合。问题是,当我尝试使用此代码显示它时:
<ScrollViewer Grid.Row="2">
<Grid Margin="10, 10,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<ListView x:Name="ListMessages" Foreground="White" ItemsSource="{Binding MessagesCollection}" IsHitTestVisible="False">
<ListView.Background>
<ImageBrush ImageSource="Public\Images\chat_green-textarea.png"/>
</ListView.Background>
<ListView.View>
<GridView ColumnHeaderContainerStyle="{DynamicResource MyHeaderStyle}">
<GridViewColumn Width="auto" DisplayMemberBinding="{Binding Message}" />
</GridView>
</ListView.View>
</ListView>
</Grid>
<Grid Grid.Column="1">
</Grid>
</Grid>
<Grid Grid.Row ="1">
<Image Source="Public\Images\chat_green-textarea-tail.png" Height="20" Width="30" HorizontalAlignment="Left" Margin="8,-4,0,0"/>
</Grid>
<Grid Grid.Row ="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<Label Foreground="white" FontSize="12">Sent by</Label>
</Grid>
<Grid Grid.Column="1">
<ListView x:Name="ListMessages2" Foreground="Black" ItemsSource="{Binding MessagesCollection}" IsHitTestVisible="False" >
<ListView.View>
<GridView ColumnHeaderContainerStyle="{DynamicResource MyHeaderStyle}">
<GridViewColumn Width="auto" DisplayMemberBinding="{Binding Name}" />
</GridView>
</ListView.View>
</ListView>
</Grid>
</Grid>
</Grid>
</ScrollViewer>
显示器是这样的。
我想要的是这样的:
Message
Sender
在集合中的每个数据中。我知道我显示它的方式是问题所在。但我真的不知道该怎么做。有任何想法吗?谢谢!