0
是否可以將顏色更改爲xaml中給定的文本單元格?listview中元素的不同顏色
在我的情況下,我想根據給定的值將顏色更改爲給定的元素。 我試圖在視單元中使用backgroundcolor,但這會影響所有元素。
有什麼辦法隻影響一個給定的單元格?
這是我的XAML代碼:
<StackLayout>
<ListView x:Name="postListView" ItemSelected="Handle_ItemSelected">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell >
<StackLayout Orientation="Horizontal" BackgroundColor="Green">
<Label Text="{Binding Description}"/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
您可以將bgcolor綁定到你的數據的值,並使用ValueConverter的數據值轉換成適當的顏色 – Jason