Пример #1
0
void
Border::OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error)
{
	if (args->GetProperty ()->GetOwnerType() != Type::BORDER) {
		FrameworkElement::OnPropertyChanged (args, error);
		return;
	}
	
	if (args->GetId () == Border::ChildProperty){
		if (args->GetOldValue() && args->GetOldValue()->AsUIElement()) {
			ElementRemoved (args->GetOldValue()->AsUIElement ());
			SetSubtreeObject (NULL);
			if (args->GetOldValue()->Is(GetDeployment (), Type::FRAMEWORKELEMENT)) {
				args->GetOldValue()->AsFrameworkElement()->SetLogicalParent (NULL, error);
				if (error->number)
					return;
			}
				
		}
		if (args->GetNewValue() && args->GetNewValue()->AsUIElement()) {
			SetSubtreeObject (args->GetNewValue()->AsUIElement());
			ElementAdded (args->GetNewValue()->AsUIElement ());
			if (args->GetNewValue()->Is(GetDeployment (), Type::FRAMEWORKELEMENT)) {
				FrameworkElement *fwe = args->GetNewValue()->AsFrameworkElement ();
				if (fwe->GetLogicalParent() && fwe->GetLogicalParent() != this) {
					MoonError::FillIn (error, MoonError::ARGUMENT, "Content is already a child of another element");
					return;
				}

				args->GetNewValue()->AsFrameworkElement()->SetLogicalParent (this, error);
				if (error->number)
					return;
			}
		}

		UpdateBounds ();
		InvalidateMeasure ();
	}
	else if (args->GetId () == Border::PaddingProperty
		 || args->GetId () == Border::BorderThicknessProperty) {
		InvalidateMeasure ();
	} else if (args->GetId () == Border::BackgroundProperty) {
		Invalidate ();
	} else if (args->GetId () == Border::BorderBrushProperty) {
		Invalidate ();
	}
	NotifyListenersOfPropertyChange (args, error);
}
Пример #2
0
void
Control::ElementAdded (UIElement *item)
{
    MoonError e;
    item->SetParent (this, &e);
    SetSubtreeObject (item);
    FrameworkElement::ElementAdded (item);
}