我想換一個PivotItem頭的於地面的顏色,當鼠標移動到與UWP,我的工作與Windows 10UWP - PivotItem鼠標移到變色
我試過這段代碼:
<Page.Resources>
<SolidColorBrush x:Key="mouseOverColor"
Color="Red" />
</Page.Resources>
<Pivot HeaderTemplate="{StaticResource HeaderTemp}" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="10,0,10,0">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState x:Name="Narrow">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="0" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="Icon.(RelativePanel.AlignHorizontalCenterWithPanel)" Value="True" />
<Setter Target="LabelText.(RelativePanel.Below)" Value="Icon" />
<Setter Target="LabelText.(RelativePanel.AlignHorizontalCenterWith)" Value="Icon" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Wide">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="500" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="Icon.(RelativePanel.AlignVerticalCenterWithPanel)" Value="True" />
<Setter Target="LabelText.(RelativePanel.RightOf)" Value="Icon" />
<Setter Target="LabelText.(RelativePanel.AlignVerticalCenterWith)" Value="Icon" />
<Setter Target="RelativePanel.Margin" Value="0,0,12,0"/>
<Setter Target="Icon.Margin" Value="0,0,0,0"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Pivot.Resources>
<Style x:Key="myStyle" TargetType="PivotItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="PivotItem">
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver"
Value="True">
<Setter Property="Background"
Value="{StaticResource mouseOverColor}" />
</Trigger>
</ControlTemplate.Triggers>
<ContentPresenter />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Pivot.Resources>
<PivotItem Header="/images/img.png" Margin="12,10,12,0" >
<Grid>
.....
</Grid>
</PivotItem>
我有錯誤「在'ControlTemplate'類型中找不到'可附加屬性'觸發器' 請您有任何想法如何在鼠標在通用應用程序中結束時更改圖像的顏色 感謝您的幫助
創建兩張圖片,堆疊它們並根據鼠標顯示/隱藏可能更容易。或者製作一張圖片,爲前景部分使用透明顏色,將其疊加在矩形的頂部,並根據鼠標懸停更改矩形的填充。 –