@@ -74,17 +74,18 @@ public double DownVerticalOffset
7474
7575 #region Background property
7676
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 ) ) ) ;
8281
82+ public static readonly DependencyProperty BackgroundProperty =
83+ BackgroundPropertyKey . DependencyProperty ;
8384
8485 public Brush Background
8586 {
8687 get { return ( Brush ) GetValue ( BackgroundProperty ) ; }
87- set { SetValue ( BackgroundProperty , value ) ; }
88+ private set { SetValue ( BackgroundPropertyKey , value ) ; }
8889 }
8990
9091 #endregion
@@ -140,8 +141,8 @@ private void SetChildTemplateIfNeed(ControlTemplate template)
140141 private void SetupBackground ( IEnumerable < DependencyObject > visualAncestry )
141142 {
142143 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 ) ;
145146
146147 if ( background != null )
147148 {
0 commit comments