private void SaveLayout() { if (UserInterfaceLayoutRepository == null || string.IsNullOrWhiteSpace(LayoutName)) { return; } if (_userInterfaceLayoutModel == null) { _userInterfaceLayoutModel = new UserInterfaceLayoutModel { LayoutName = LayoutName }; } using (MemoryStream stream = new MemoryStream()) { AssociatedObject.SaveLayout(stream); stream.Position = 0; using (StreamReader sr = new StreamReader(stream)) { _userInterfaceLayoutModel.MainViewDockingData = sr.ReadToEnd(); UserInterfaceLayoutRepository.Save(_userInterfaceLayoutModel); } } }