2

我在 Xamarin Forms 中有一个基本的自定义 Listview 单元格,如下所示。

我正在设置背景颜色并使用 StackLayout Padding 进行包装以模仿底部边框。

在 UWP 中,我现在如何更新单元格“悬停”颜色,使其在悬停在单元格上时发生变化?

我只能在没有设置背景时显示浅灰色悬停颜色(默认白色)

<ViewCell.View>

        <StackLayout Padding="0,0,0,1" BackgroundColor="#183c57">

          <Grid Padding="8,5" BackgroundColor="#f2f2f2">
            <Grid.ColumnDefinitions>
              <ColumnDefinition Width="*"/>
              <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <StackLayout Grid.Column="0"
                         Padding="4"
                         Spacing="2"
                         VerticalOptions="Center">
              <Label Text="{Binding ActivityID}" FontSize="Small" FontAttributes="Bold"   TextColor="#183c57" LineBreakMode="TailTruncation" />
              <Label Text="{Binding RouteId}" FontSize="Micro" TextColor="#444444" LineBreakMode="TailTruncation"/>
              <Label Text="{Binding Description}" FontSize="Micro" TextColor="#444444" LineBreakMode="TailTruncation"/>

            </StackLayout>

            <StackLayout Grid.Column="1" VerticalOptions="Start" Spacing="0" Padding="3" BackgroundColor="{Binding HexColorReadable}"  Margin="0, 4, 10, 0">
              <Label Text="{Binding StatusId}" FontSize="Micro" FontAttributes="Bold" TextColor="#000000"  XAlign="End"  />
            </StackLayout>

          </Grid>
        </StackLayout>
</ViewCell.View>

我已经尝试过类似这样的更新App.xamlUWP 项目的方法,但它不起作用。

<Application.Resources>
    <ResourceDictionary>

        <Style x:Key="FormsListViewItem" TargetType="ListViewItem">

            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListViewItem">
                        <ListViewItemPresenter PointerOverForeground="Blue"

                 />
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>


    </ResourceDictionary>
</Application.Resources>
4

0 回答 0