//private void TextBoxUnLoaded(object sender, RoutedEventArgs e) //{ // Detach(); //} private void TextBoxLoaded(object sender, RoutedEventArgs e) { m_TextBlockAdorner = new TextBlockAdorner(m_TextBox, GetLabel(m_TextBox), GetLabelStyle(m_TextBox)); UpdateAdorner(); // DependencyPropertyDescriptor focusProp = DependencyPropertyDescriptor.FromProperty(UIElement.IsFocusedProperty, typeof(TextBox));//FrameworkElement // if (focusProp != null) // { //#if HANDLE_MEM_LEAK // focusProp.AddValueChanged(m_TextBox, OnValueChanged_IsFocusedProperty); // m_TextBox.SetValue(IsFocusedPropertyDescriptor, focusProp); //#else // focusProp.AddValueChanged(m_TextBox, (sender, args) => UpdateAdorner()); //#endif //HANDLE_MEM_LEAK // } // DependencyPropertyDescriptor containsTextProp = DependencyPropertyDescriptor.FromProperty(HasTextProperty, typeof(TextBox)); // if (containsTextProp != null) // { //#if HANDLE_MEM_LEAK // containsTextProp.AddValueChanged(m_TextBox, OnValueChanged_HasTextProperty); // m_TextBox.SetValue(HasTextPropertyDescriptor, containsTextProp); //#else // containsTextProp.AddValueChanged(m_TextBox, (sender, args) => UpdateAdorner()); //#endif //HANDLE_MEM_LEAK // } }
private void ComboBoxLoaded(object senderz, RoutedEventArgs e) { var textBox = GetTextBox(); if (textBox != null) { textBox.TextChanged += ComboBoxTextChanged; } m_TextBlockAdorner = new TextBlockAdorner(m_ComboBox, GetLabel(m_ComboBox), GetLabelStyle(m_ComboBox)); UpdateAdorner(); // DependencyPropertyDescriptor focusProp = DependencyPropertyDescriptor.FromProperty(UIElement.IsFocusedProperty, typeof(ComboBox)); // if (focusProp != null) // { //#if HANDLE_MEM_LEAK // focusProp.AddValueChanged(m_ComboBox, OnValueChanged_IsFocusedProperty); // m_ComboBox.SetValue(IsFocusedPropertyDescriptor, focusProp); //#else // focusProp.AddValueChanged(m_ComboBox, (sender, args) => UpdateAdorner()); //#endif //HANDLE_MEM_LEAK // } // DependencyPropertyDescriptor focusKeyboardProp = DependencyPropertyDescriptor.FromProperty(UIElement.IsKeyboardFocusedProperty, typeof(ComboBox)); // if (focusKeyboardProp != null) // { //#if HANDLE_MEM_LEAK // focusKeyboardProp.AddValueChanged(m_ComboBox, OnValueChanged_IsKeyboardFocusedProperty); // m_ComboBox.SetValue(IsKeyboardFocusedPropertyDescriptor, focusKeyboardProp); //#else // focusKeyboardProp.AddValueChanged(m_ComboBox, (sender, args) => UpdateAdorner()); //#endif //HANDLE_MEM_LEAK // } // DependencyPropertyDescriptor focusKeyboardWithinProp = DependencyPropertyDescriptor.FromProperty(UIElement.IsKeyboardFocusWithinProperty, typeof(ComboBox)); // if (focusKeyboardWithinProp != null) // { //#if HANDLE_MEM_LEAK // focusKeyboardWithinProp.AddValueChanged(m_ComboBox, OnValueChanged_IsKeyboardFocusWithinProperty); // m_ComboBox.SetValue(IsKeyboardFocusWithinPropertyDescriptor, focusKeyboardWithinProp); //#else // focusKeyboardWithinProp.AddValueChanged(m_ComboBox, (sender, args) => UpdateAdorner()); //#endif //HANDLE_MEM_LEAK // } // DependencyPropertyDescriptor textProp = DependencyPropertyDescriptor.FromProperty(ComboBox.TextProperty, typeof(ComboBox)); // if (textProp != null) // { //#if HANDLE_MEM_LEAK // textProp.AddValueChanged(m_ComboBox, OnValueChanged_TextProperty); // m_ComboBox.SetValue(TextPropertyDescriptor, textProp); //#else // textProp.AddValueChanged(m_ComboBox, (sender, args) => UpdateAdorner()); //#endif //HANDLE_MEM_LEAK // } // DependencyPropertyDescriptor selectedIndexProp = DependencyPropertyDescriptor.FromProperty(Selector.SelectedIndexProperty, typeof(ComboBox)); // if (selectedIndexProp != null) // { //#if HANDLE_MEM_LEAK // selectedIndexProp.AddValueChanged(m_ComboBox, OnValueChanged_SelectedIndexProperty); // m_ComboBox.SetValue(SelectedIndexPropertyDescriptor, selectedIndexProp); //#else // selectedIndexProp.AddValueChanged(m_ComboBox, (sender, args) => UpdateAdorner()); //#endif //HANDLE_MEM_LEAK // } // DependencyPropertyDescriptor selectedItemProp = DependencyPropertyDescriptor.FromProperty(Selector.SelectedItemProperty, typeof(ComboBox)); // if (selectedItemProp != null) // { //#if HANDLE_MEM_LEAK // selectedItemProp.AddValueChanged(m_ComboBox, OnValueChanged_SelectedItemProperty); // m_ComboBox.SetValue(SelectedItemPropertyDescriptor, selectedItemProp); //#else // selectedItemProp.AddValueChanged(m_ComboBox, (sender, args) => UpdateAdorner()); //#endif //HANDLE_MEM_LEAK // } }