简体   繁体   English

Xamarin形成UWP ListView MouseHover颜色

[英]Xamarin Forms UWP ListView MouseHover Color

Hello , 你好

I tried to change the mouse hover only in ListView colors. 我试图仅在ListView颜色中更改鼠标悬停。 But I did not succeed. 但是我没有成功。

I need this feature only UWP project. 我只需要此功能的UWP项目。

Anyone can help me? 有人可以帮助我吗?

In UWP platform App.xaml, you modify listViewItem PointerOverBackground : 在UWP平台App.xaml中,您可以修改listViewItem PointerOverBackground

<Application
x:Class="App2.UWP.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App2.UWP"
RequestedTheme="Light">

<Application.Resources>
    <ResourceDictionary>

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

            <Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />

            <Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />

            <Setter Property="Background" Value="Transparent" />

            <Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseHighBrush}" />

            <Setter Property="TabNavigation" Value="Local" />

            <Setter Property="IsHoldingEnabled" Value="True" />

            <Setter Property="Padding" Value="0" />

            <Setter Property="HorizontalContentAlignment" Value="Stretch" />

            <Setter Property="VerticalContentAlignment" Value="Center" />

            <Setter Property="MinWidth" Value="{ThemeResource ListViewItemMinWidth}" />

            <Setter Property="MinHeight" Value="0" />

            <Setter Property="Template">

                <Setter.Value>

                    <ControlTemplate TargetType="ListViewItem">

                        <ListViewItemPresenter
                            HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                            VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                            CheckBoxBrush="{ThemeResource SystemControlForegroundBaseMediumHighBrush}"
                            CheckBrush="{ThemeResource SystemControlForegroundBaseMediumHighBrush}"
                            CheckMode="Inline"
                            ContentMargin="{TemplateBinding Padding}"
                            ContentTransitions="{TemplateBinding ContentTransitions}"
                            DisabledOpacity="{ThemeResource ListViewItemDisabledThemeOpacity}"
                            DragBackground="{ThemeResource ListViewItemDragBackgroundThemeBrush}"
                            DragForeground="{ThemeResource ListViewItemDragForegroundThemeBrush}"
                            DragOpacity="{ThemeResource ListViewItemDragThemeOpacity}"
                            FocusBorderBrush="{ThemeResource SystemControlForegroundAltHighBrush}"
                            FocusSecondaryBorderBrush="{ThemeResource SystemControlForegroundBaseHighBrush}"
                            PlaceholderBackground="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}"
                            PointerOverBackground="{ThemeResource SystemControlAccentDark1AcrylicElementAccentDark1Brush}"
                            PointerOverForeground="{ThemeResource SystemControlHighlightAltBaseHighBrush}"
                            PressedBackground="{ThemeResource SystemControlHighlightListMediumBrush}"
                            ReorderHintOffset="{ThemeResource ListViewItemReorderHintThemeOffset}"
                            SelectedBackground="{ThemeResource SystemControlHighlightListAccentLowBrush}"
                            SelectedForeground="{ThemeResource SystemControlHighlightAltBaseHighBrush}"
                            SelectedPointerOverBackground="{ThemeResource SystemControlHighlightListAccentMediumBrush}"
                            SelectedPressedBackground="{ThemeResource SystemControlHighlightListAccentHighBrush}"
                            SelectionCheckMarkVisualEnabled="True" />

                    </ControlTemplate>

                </Setter.Value>

            </Setter>

        </Style>

    </ResourceDictionary>

</Application.Resources>

Now you will change ListView mouse hover color. 现在,您将更改ListView鼠标悬停颜色。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM