我在 WPF 应用程序中进行了边界控制。我想改变设定焦点的背景。为此,编写了以下代码,但它不起作用。
Style _Style = new System.Windows.Style(typeof(Border));
Trigger _Trigger = new Trigger();
_Trigger.Property = Border.IsFocusedProperty;
_Trigger.Value = true;
_Trigger.Setters.Add(new Setter(Border.BackgroundProperty, Brushes.Green));
_Style.Triggers.Add(_Trigger);
Border1.Style = _Style;