我在WPF應用程序中採用了邊界控制。我想改變設置焦點的背景。爲此,編寫了以下代碼,但它不起作用。如何更改WPF中Border-Control運行時的背景?
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;
這就是XAML的用途,你知道的。 – 2013-04-26 15:04:58