我正在使用RichEditBox
,我正在實施一些選項讓用戶使用某些格式編輯文本。如何在WinRT/UWP RichEditBox中保持突出顯示的文字焦點丟失?
的問題是,每一個控制丟失時間集中,高亮選擇是隱藏的,即使選擇保持活躍,我可以在它的實際工作。
以下是我正在使用的Template
,因爲您可以看到我已經刪除了所有VisualState
s,但這並未解決問題。
<Style TargetType="RichEditBox" x:Key="CustomRtfEditBoxStyle">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RichEditBox">
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Disabled" />
<VisualState x:Name="Normal" />
<VisualState x:Name="PointerOver" />
<VisualState x:Name="Focused" />
<VisualState x:Name="UnFocused" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
...
現在,我想這是沒有問題的,並且選擇在控制的內部代碼的地方管理。
注:我不能實際使用workaround手動設置選擇背景顏色時,焦點將丟失並獲得,作爲文本導出/加載豐富的文本,我不能亂了用戶設置。我需要一種方法來做到這一點,而不必實際更改格式化文本。
我注意到,RichEditBox
類不是sealed
,所以我想知道是否有可能重寫某些行爲或做一些事情來解決這個問題,但我不知道從哪裏開始。 我知道在WPF上還有其他一些解決方法可以解決這個問題(比如在失去焦點時保持突出顯示的便利屬性),但UWP中不存在這個問題。
你有什麼想法如何做到這一點?謝謝!
這是另一種解決方法:https://stackoverflow.com/questions/37524488/uwp-show-textbox-text-highlight-while-textbox-is-out-of-focus –