System.Windows.Data.BindingExpressionBase.OnAttached C# (CSharp) Method

OnAttached() private method

private OnAttached ( DependencyObject element ) : void
element System.Windows.DependencyObject
return void
		internal override void OnAttached (DependencyObject element)
		{
			base.OnAttached (element);
			if (TwoWayTextBoxText)
				((TextBox) Target).LostFocus += TextBoxLostFocus;

			if (IsMentorBound) {
				Target.MentorChanged += MentorChanged;
				mentor = Target.Mentor;
				AttachDataContextHandlers (mentor);
			}

			if (Binding.Mode == BindingMode.TwoWay && Property is CustomDependencyProperty) {
				updateDataSourceCallback = delegate {
					try {
						if (!Updating)
							TryUpdateSourceObject (Target.GetValue (Property));
					} catch (Exception ex) {
						try {
							Console.WriteLine ("Moonlight: Unhandled exception in BindingExpressionBase.OnAttached's updateDataSourceCallback: {0}", ex);
						} catch {
							// Ignore
						}
					}
				};
				NativeMethods.dependency_object_add_property_change_handler (Target.native, Property.Native, updateDataSourceCallback, IntPtr.Zero);
			}
		}