コード例 #1
0
        private static void OnEnableWatermarkChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (e.OldValue != null)
            {
                var enabled = (bool)e.OldValue;

                if (enabled)
                {
                    var comboBox = (CheckComboBox)d;
                    var behavior = GetWatermarkCheckComboBoxBehavior(comboBox);
                    behavior.Detach();

                    SetWatermarkCheckComboBoxBehavior(comboBox, null);
                }
            }

            if (e.NewValue != null)
            {
                var enabled = (bool)e.NewValue;

                if (enabled)
                {
                    var comboBox = (CheckComboBox)d;
                    var behavior = new WatermarkCheckComboBoxBehavior(comboBox);
                    behavior.Attach();

                    SetWatermarkCheckComboBoxBehavior(comboBox, behavior);
                }
            }
        }
コード例 #2
0
 private static void SetWatermarkCheckComboBoxBehavior(DependencyObject obj, WatermarkCheckComboBoxBehavior value)
 {
     obj.SetValue(WatermarkCheckComboBoxBehaviorProperty, value);
 }