[英]How do I change the OnMouseHover behavior of an Editor Control in Xamarin.Forms
我正在Xamarin.Forms
设计一个应用程序,并且正在使用如下的Editor
控件:
我在UWP上运行它,当我将鼠标悬停在控件上时,背景色反转为黑色。 请参阅下面的图像:
如您所见,非常可怕。
我感觉到可能与此ThemeResource样式有关。我还可以看到,在WinRT平台上(我认为UWP使用相同的控件) 肯定使用了该样式,但是我对样式还不了解告诉这可能与这条线特别有关
确实,问题出在您期望的地方。 在您的情况下,VisualState PointerOver将边框画笔和背景的不透明度设置为新值。 如果要保持背景不变,只需删除下面代码中标记的部分即可。
我可能会保持边框笔刷突出显示,以便用户仍然可以看到控件已聚焦。 但是,如果需要,您也可以删除它(实际上是整个视觉状态)。
<VisualState x:Name="PointerOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="BorderElement">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightChromeAltLowBrush}" />
</ObjectAnimationUsingKeyFrames>
<!-- Remove the following -->
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BackgroundElement">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlBackgroundHoverOpacity}" />
</ObjectAnimationUsingKeyFrames>
<!-- until here -->
</Storyboard>
</VisualState>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.