コード例 #1
0
        private async Task EditSessionDialog(SessionViewModel sessionVM)
        {
            if (sessionVM == null)
            {
                return;
            }

            var editWindow = new ModalOkCancelControl();

            try
            {
                //editWindow.Width = 700;
                //editWindow.Height = 650;
                var content = new SessionEditControl();
                MainGrid.Children.Add(editWindow);

                editWindow.Title = "Edit Session";

                var editVM = content.DataContext as SessionViewModel;
                if (sessionVM.SessionType == Enums.SessionType.Race)
                {
                    editVM.UpdateSource(Models.Sessions.RaceSessionModel.GetTemplate());
                }
                editVM.Model.CopyFrom(sessionVM.Model);
                editVM.Schedule = sessionVM.Schedule;

                editWindow.ModalContent = content;
                if (editWindow.ShowDialog() == true)
                {
                    sessionVM.Model.CopyFrom(editVM.Model);
                    await sessionVM.SaveChanges();
                }
            }
            finally
            {
                MainGrid.Children.Remove(editWindow);
            }
        }