@@ -74,17 +74,18 @@ public double DownVerticalOffset
74
74
75
75
#region Background property
76
76
77
- public static readonly DependencyProperty BackgroundProperty
78
- = DependencyProperty . Register ( nameof ( Background ) ,
79
- typeof ( Brush ) ,
80
- typeof ( ComboBoxPopup ) ,
81
- new FrameworkPropertyMetadata ( Brushes . Transparent , FrameworkPropertyMetadataOptions . AffectsRender ) ) ;
77
+ private static readonly DependencyPropertyKey BackgroundPropertyKey =
78
+ DependencyProperty . RegisterReadOnly (
79
+ "Background" , typeof ( Brush ) , typeof ( ComboBoxPopup ) ,
80
+ new PropertyMetadata ( default ( Brush ) ) ) ;
82
81
82
+ public static readonly DependencyProperty BackgroundProperty =
83
+ BackgroundPropertyKey . DependencyProperty ;
83
84
84
85
public Brush Background
85
86
{
86
87
get { return ( Brush ) GetValue ( BackgroundProperty ) ; }
87
- set { SetValue ( BackgroundProperty , value ) ; }
88
+ private set { SetValue ( BackgroundPropertyKey , value ) ; }
88
89
}
89
90
90
91
#endregion
@@ -140,8 +141,8 @@ private void SetChildTemplateIfNeed(ControlTemplate template)
140
141
private void SetupBackground ( IEnumerable < DependencyObject > visualAncestry )
141
142
{
142
143
var background = visualAncestry
143
- . Select ( v => ( v as Control ) ? . Background ?? ( v as Border ) ? . Background )
144
- . FirstOrDefault ( v => v != null && v != Brushes . Transparent && v is SolidColorBrush ) ;
144
+ . Select ( v => ( v as Control ) ? . Background ?? ( v as Panel ) ? . Background ?? ( v as Border ) ? . Background )
145
+ . FirstOrDefault ( v => v != null && ! Equals ( v , Brushes . Transparent ) && v is SolidColorBrush ) ;
145
146
146
147
if ( background != null )
147
148
{
0 commit comments