【问题标题】:Xamarin Forms UWP ListView MouseHover ColorXamarin Forms UWP ListView MouseHover 颜色
【发布时间】:2019-08-12 17:47:15
【问题描述】:

你好,

我尝试仅在 ListView 颜色中更改鼠标悬停。但我没有成功。

我只需要这个功能的 UWP 项目。

谁能帮帮我?

【问题讨论】:

    标签: xamarin xamarin.forms xamarin.uwp


    【解决方案1】:

    在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>
    

    现在您将更改 ListView 鼠标悬停颜色。

    【讨论】:

      猜你喜欢
      • 2017-11-23
      • 2019-06-20
      • 2020-06-27
      • 1970-01-01
      • 2017-01-05
      • 2021-12-05
      • 2016-05-09
      • 2017-10-03
      • 2020-04-09
      相关资源
      最近更新 更多