public IObjectContainer AddMasterPageObject(Guid masterPageGuid, Guid viewGuid, double x = 0, double y = 0) { IObjectContainer container = ParentPage.AddMasterPageObject(masterPageGuid, viewGuid); IMasterPage masterPage = ParentDocument.MasterPages[masterPageGuid]; masterPage.Open(); PageView masterPageView = masterPage.PageViews[viewGuid] as PageView; if (masterPageView == null) { masterPageView = masterPage.PageViews[ParentDocument.AdaptiveViewSet.Base.Guid] as PageView; } double xDelta = masterPageView.PageViewStyle.X - x; double yDelta = masterPageView.PageViewStyle.Y - y; foreach (Widget widget in container.WidgetList) { // Set the created view as the current view because this is the first time when the widget // is added in the current document. widget.CreatedViewGuid = _viewGuid; // Set this flag to false. PlaceWidgetInternal method will set this flag base on checking // if this is base view. widget.HasBeenPlacedInBaseView = false; // Get widget style in this view. IWidgetStyle widgetViewStyle = widget.GetWidgetStyle(_viewGuid); // Widgets in master page should have same relative location, so make them have the same delta. widgetViewStyle.X -= xDelta; widgetViewStyle.Y -= yDelta; if (widget is IHamburgerMenu) { IHamburgerMenu menu = widget as IHamburgerMenu; IHamburgerMenuButton button = menu.MenuButton; IWidgetStyle buttonViewStyle = button.GetWidgetStyle(_viewGuid); buttonViewStyle.X -= xDelta; buttonViewStyle.Y -= yDelta; } PlaceWidgetInternal(widget, true); } // Master Page doesn't contain masters, so we don't handle container.MasterList. return(container); }