【发布时间】:2023-03-22 01:11:01
【问题描述】:
我正在为我的项目使用 xamarin.forms。我有如下列表视图:
<ListView x:Name="lst_port" HasUnevenRows="True">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Frame Style="{StaticResource FrmDashboard}" Margin="5">
<StackLayout>
<StackLayout.GestureRecognizers>
<TapGestureRecognizer Tapped="OnPortering_Tapped"></TapGestureRecognizer>
</StackLayout.GestureRecognizers>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="0" Style="{StaticResource LISTTitleLabel}" Text="{Binding PorteringNumber}"></Label>
<Button Grid.Row="0" Grid.Column="0" Style="{StaticResource LISTTitleButton}" Text="{Binding PorteringStatus}" BackgroundColor="#2d964c"></Button>
</Grid>
<StackLayout Orientation="Horizontal">
<Image Style="{StaticResource LISTImageIcon}" Source="note.png"/>
<Label Style="{StaticResource LISTBodyLabel}" Text="{Binding PorteringAssetNumber}"></Label>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Image Style="{StaticResource LISTImageIcon}" Source="clock.png"/>
<Label Style="{StaticResource LISTBodyLabel1}" Text="{Binding PorteringDate}"></Label>
<Image Style="{StaticResource LISTImageIcon}" Source="calender.png"/>
<Label Style="{StaticResource LISTBodyLabel1}" Text="{Binding PorteringTime}"></Label>
</StackLayout>
</StackLayout>
</Frame>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
我使用数据表后面的代码将值分配给列表视图。 结果如下图所示:
现在我想改变按钮的背景颜色,当绑定文本是“紧急”时。
【问题讨论】:
标签: xamarin.forms