void SpreadsheetComponentControl_Loaded(object sender, RoutedEventArgs e) { DesignerItem parent = this.Parent as DesignerItem; data.BindPositionToCanvas(parent); data.PropertyChanged += data_PropertyChanged; // add Export Excel context menu to DesignerItem List <MenuItem> menuItems = new List <MenuItem>(); MenuItem exportItem = new MenuItem() { Header = "Export to Excel", Command = Command.ExportExcel }; menuItems.Add(exportItem); parent.AddContextMenuItems(menuItems); grid.UpdateLayout(); for (int row = 0; row < this.grid.Items.Count; ++row) { UpdateRow(row); } UpdateDisplay(); }