private void Button_Click(object sender, RoutedEventArgs e) { const string layoutValuePropertyName = "LayoutValue"; var dlgmodel = new DialogLayoutViewModel { Title = "Настройка диалога", DialogHeder = "Диалог", LayoutHeder = "Свойства", LayoutValue = ModelItem.Properties[layoutValuePropertyName].ComputedValue.To <string>() }; var collection = ModelItem.Properties["Fields"].Collection; var actualCollection = collection.GetCurrentValue() as IEnumerable <ValueDataField>; dlgmodel.Fields.AddRange(actualCollection); dlgmodel.UpdateSource(); var viewService = IoC.Instance.Resolve <IViewService>(); if (viewService.ShowDialogWindow(viewModel: dlgmodel, isRestoredLayout: false) == true) //Не менять isRestoredLayout на true. Проблемы с отображением формы в WorkflowDesigner'е. { using (var scope = collection.BeginEdit()) { ModelItem.Properties[layoutValuePropertyName].SetValue(dlgmodel.LayoutValue); scope.Complete(); } } }
private void FillGroup(LayoutGroup group, DialogLayoutViewModel vm) { if (vm.Source != null) { group.DataContext = vm.Source; } foreach (var field in vm.Fields.OrderBy(p => p.Order).ToArray()) { var oldLayout = FindName(field.Name); if (oldLayout != null) { continue; } LayoutItem layoutItem; if (field.FieldType == typeof(Button) || field.FieldType == typeof(IFooterMenu)) { var button = new Button { Content = field.Caption, HorizontalContentAlignment = HorizontalAlignment.Left }; if (vm.FontSize > 0) { button.FontSize = vm.FontSize; } layoutItem = new LayoutItem { Name = field.Name, IsEnabled = !field.IsEnabled.HasValue || field.IsEnabled.Value, Visibility = field.Visible ? Visibility.Visible : Visibility.Collapsed, Content = button }; } else { layoutItem = new CustomDataLayoutItem(field) { IsVisibilitySetOutside = true, IsDisplayFormatSetOutside = true, //ParentViewModelSource = vm.ParentViewModelSource, }; } if (vm.FontSize > 0) { layoutItem.FontSize = vm.FontSize; } layoutItem.Tag = field; //т.к. испоьзуем ExpandoObject - регистрируем здесь RegisterName(field.Name, layoutItem); group.Children.Add(layoutItem); } }
public DialogLayoutView() { InitializeComponent(); DataContextChanged += (s, e) => { _model = DataContext as DialogLayoutViewModel; if (_model == null) { return; } RefreshBinding(); }; Loaded += delegate { RestoreLayout(); objectDataLayout.IsCustomization = true; objectDataLayout.Controller.CustomizationController.SelectionChanged -= OnSelectionChangedCustomizationController; objectDataLayout.Controller.CustomizationController.SelectionChanged += OnSelectionChangedCustomizationController; }; }