2017-02-09 39 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