在問這個問題之前,我研究并測驗了很多代碼。
IDE:VS2022。作業系統:Windows 11。應用程式:(WPF .NET 6核心)C# T-SQL
我正在嘗試覆寫資源字典中的
我究竟做錯了什么?
感謝您的幫助。
更新:
使用樣式不起作用。
<Style TargetType="PasswordBox">
<Setter Property="SelectionBrush" Value="Red" />
<Setter Property="SelectionTextBrush" Value="Red" />
</Style>

uj5u.com熱心網友回復:
TextBox并PasswordBox通過他們的SelectionBrush財產控制他們的高光筆刷。并非所有控制元件都使用SystemColors.HighlightBrushKey. SystemColors.HighlightBrushKey由DataGrid例如使用,但不由ListBox.
使用SelectionOpacity控制高亮畫筆的不透明度。
要更改SelectionBrush全域,您必須Style向App.xaml資源添加一個:
應用程式.xaml
<ResourceDictionary>
<Style TargetType="PasswordBox">
<Setter Property="SelectionBrush" Value="Red" />
<Setter Property="SelectionOpacity" Value="0.8" />
</Style>
<Style TargetType="TextBox">
<Setter Property="SelectionBrush" Value="Red" />
<Setter Property="SelectionOpacity" Value="0.8" />
</Style>
</ResourceDictionary>
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/376958.html
