c# - ListView Tapped 删除数据模板 Xamarin.Forms 上的按钮背景颜色

标签 c# ios xaml xamarin xamarin.forms

我不知道为什么,但是当我点击任何 ListView 项时,其模板中的 Button 会失去背景色。

我在 ListView 中使用默认的 ViewCell。这是 Xamarin.Forms 错误吗?

我只在 iOS 上有这个问题。

    <ListView x:Name="lv" Grid.Row="2" HasUnevenRows="true" BackgroundColor="White" ItemTapped="OnItemTapped">
 <ListView.ItemTemplate>
      <DataTemplate>
       <ViewCell>               
       <StackLayout Padding="16" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" BackgroundColor="{Binding .,Converter={StaticResource IndexColorConverter}">

        <StackLayout VerticalOptions="Center">
                  <Label Text="{Binding Auditorium}" FontSize="18" TextColor="Black"/>
                  <ContentView Padding="0,-5,0,0">
                         <Label Text="{Binding Title}" FontSize="16" TextColor="Black"/>        
                  </ContentView>
      <StackLayout Orientation="Horizontal">
         <Button WidthRequest="100" Text="{Binding ButtonOverviewText}" TextColor="White" BackgroundColor="{Binding ButtonColor}" CommandParameter="{Binding .}" Clicked="Handle_Clicked"/>
         <Button WidthRequest="100" Text="{Binding ButtonOverviewText}" TextColor="White" BackgroundColor="{Binding ButtonColor}" CommandParameter="{Binding .}" Clicked="Handle_Clicked" />
   </StackLayout>
  </StackLayout>

   <Label Text="{Binding Coordinator}" FontSize="14" TextColor="Gray"/>

   </StackLayout>
   </ViewCell>
  </DataTemplate>
</ListView.ItemTemplate>
</ListView>

button colors removed

最佳答案

我为类似的错误提交了一个旧问题:https://bugzilla.xamarin.com/show_bug.cgi?id=27502 .

但是,您提到的特定场景是 iOS 上的预期行为,并且也发生在 native (非 Xamarin.Forms)项目中。见评论here .您可以考虑使用 UITableViewCellSelectionStyle.None 禁用单元格的 UITableViewCellSelectionStyleHere是单元格渲染器的示例。您可以在此处设置 cell.SelectionStyle。这将停止单元格的灰色突出显示。如果您不希望这样做,那么保留按钮颜色可能是一种解决方法。

关于c# - ListView Tapped 删除数据模板 Xamarin.Forms 上的按钮背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41097427/

相关文章:

c# - 单元测试大脑卡住

c# - 是否有适用于 Windows Core Audio 的 COM 类型库

c# - 在 asp.net mvc 中发送电子邮件而不像在 php 中那样使用凭据

ios - 如何拦截从 CallKit 来电屏幕发送的 "Messages"?

ios - iOS“应用程序传输安全实现”是否意味着我需要将 API 切换到 https?

c# - Silverlight 元素绑定(bind)不起作用

windows-phone-7 - 为什么我不能在不将 child 的背景设置为透明的情况下点击/单击 Border/ContentControl 内的空白区域?

c# - MEF和基于元数据的导出

ios - 如何在ios中将图像添加为圆形框架

XAML 中的 WPF 合并上下文菜单