我想将图像和文本绑定在同一列中。我设法绑定文本部分但未能绑定图像部分。这就是我到目前为止所做的:
<ListView.View>
<GridView>
<GridViewColumn x:Name="TimeColumn" Header="Time" Width="80">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock>
<TextBlock.Text>
<MultiBinding>
<!--<PUT IMAGE>-->
<Binding Path="Time"/>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
这是我的预期结果:
有什么建议吗?
答案 0 :(得分:5)
您无法将文本和图像绑定到TextBlock中,因此您需要尝试以下内容:
<ListView.View>
<GridView>
<GridViewColumn x:Name="TimeColumn" Header="Time" Width="80">
<GridViewColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image /> <!-- YOU NEED TO POINT THIS TO YOUR IMAGE -->
<TextBlock Text="{Binding Time}"/>
</StackPanel>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>