2017-02-09 35 views
1

我设计的Xamarin.Forms一个应用程序,我使用的是Editor控制,像这样的OnMouseHover行为:如何改变编辑控制在Xamarin.Forms

我对UWP当运行这个我将鼠标悬停在控件上,背景颜色变为黑色。看以下图片:

没有重点 enter image description here

鼠标悬停 enter image description here

重点 enter image description here

正如你所看到的,很可怕。

我有可能与this ThemeResource Style做我也能看到的WinRT平台上的感觉(我想的一样控制用于UWP)it is definitely applying that style,但我不知道有足够的了解样式告诉 它可能与this line in particular

回答

2

确实,问题出在你期望的地方。在你的情况下,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> 
+0

这将意味着有'Xamain.Forms'的自定义生成是有办法,我可以设置'TextControlBackgroundHoverOpacity'的价值在我的'App.xaml'去改变? – user1

+0

@ user1对,没有意识到它是Xamarin.Forms的内部代码。然后我会更新UWP特定代码中TextControlBackgroundHoverOpacity的值。像这样:Windows.UI.Xaml.Application.Current.Resources [“TextControlBackgroundHoverOpacity”] = 1;您也许可以通过编程方式删除VisualState,但我正在通话并且无法立即验证它。 – hankide

+0

是否可以替换xaml中的资源? – user1