正如您在下面看到的,FlyoutItem
有一个 Icon 和一个Title
.
<FlyoutItem Title="About" >
<FlyoutItem.Icon>
<FontImageSource FontFamily="MaterialDesignIconFont"
Glyph="{StaticResource InformationOutlineGlyph}"
Color="Green" />
</FlyoutItem.Icon>
<ShellContent Route="AboutPage" ContentTemplate="{DataTemplate local:AboutPage}" />
</FlyoutItem>
由于这个Title
原因,颜色会自动更改Style
:
<Style Class="FlyoutItemLayoutStyle" TargetType="Layout" ApplyToDerivedTypes="True">
<Setter Property="BackgroundColor" Value="LightBlue"></Setter>
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal">
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="White" />
<Setter TargetName="FlyoutItemLabel" Property="Label.TextColor" Value="{StaticResource PrimaryColor}" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Selected">
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="{StaticResource PrimaryColor}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
So the Label
that is the Title
changes color automatically when the FlyoutItem
is selected. 我需要Icon
做同样的事情。我可以使用触发器来设置,FontImageSource
但这有其自身的问题。
鉴于TargetName
上面的“FlyoutItemLabel” Style
,是否可以创建从FontImageSource.Color
到 eachFlyoutItem
的绑定"FlyoutItemLabel".Color
?它必须向上绑定到FlyoutItem
祖先,然后向下绑定到<Label x:Name="FlyoutItemLabel" />
,不是吗?