private static void ChangeCoordinateProperty(DependencyObject d, DependencyPropertyChangedEventArgs e) { ButtonEx sprite = (ButtonEx)d; if (sprite.IsVisible) { Point oldCoordinate = (Point)e.OldValue; Point newCoordinate = (Point)e.NewValue; Canvas.SetLeft(sprite, newCoordinate.X - 16); Canvas.SetTop(sprite, newCoordinate.Y - 16); } }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.Layroot = ((System.Windows.Controls.Canvas)(target)); return; case 2: this.button1 = ((WpfApplication1.ButtonEx)(target)); return; } this._contentLoaded = true; }