void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.input = ((Model_Struct_Builder.InputDropDown)(target)); return; case 2: this.Front = ((System.Windows.Controls.ComboBox)(target)); return; case 3: this.Back = ((System.Windows.Controls.TextBox)(target)); return; } this._contentLoaded = true; }
void LoadContent() { DialogueWindowViewModel VM = DataContext as DialogueWindowViewModel; foreach (FormStruct formItem in VM.FormStructs) { switch (formItem.type) { case FormItemType.InputLine: InputLine tmpInputLine = new InputLine(); tmpInputLine.Margin = new Thickness(0, 0, 0, 20); tmpInputLine.InputAreaWidth = 400; tmpInputLine.InputName = formItem.name; VM.CallBackValues.Add("Value", ""); BindingOperations.SetBinding(tmpInputLine, InputLine.InputTextProperty, new Binding() { Path = new PropertyPath("CallBackValues[Value]"), Mode = BindingMode.TwoWay }); MainPanel.Children.Add(tmpInputLine); break; case FormItemType.InputText: break; case FormItemType.DropDown: DropDown tmpDropDown = new DropDown(); tmpDropDown.Margin = new Thickness(0, 0, 0, 20); tmpDropDown.InputAreaWidth = 400; tmpDropDown.InputName = formItem.name; tmpDropDown.InputList = formItem.parameters as List <string>; VM.CallBackValues.Add("Value", tmpDropDown.InputList[0]); BindingOperations.SetBinding(tmpDropDown, DropDown.SelectedItemProperty, new Binding() { Path = new PropertyPath("CallBackValues[Value]"), Mode = BindingMode.TwoWay }); MainPanel.Children.Add(tmpDropDown); break; case FormItemType.InputDropDown: InputDropDown tmpInputDropDown = new InputDropDown(); tmpInputDropDown.Margin = new Thickness(0, 0, 0, 20); tmpInputDropDown.InputAreaWidth = 400; tmpInputDropDown.InputName = formItem.name; tmpInputDropDown.InputList = formItem.parameters as List <string>; VM.CallBackValues.Add("Value", ""); BindingOperations.SetBinding(tmpInputDropDown, InputDropDown.EffectiveValueProperty, new Binding() { Path = new PropertyPath("CallBackValues[Value]"), Mode = BindingMode.TwoWay }); MainPanel.Children.Add(tmpInputDropDown); break; } } Button button = new Button(); BindingOperations.SetBinding(button, Button.CommandProperty, new Binding() { Path = new PropertyPath("CallbackCommand"), }); button.Content = "确定"; button.Click += (sender, e) => { this.Close(); }; MainPanel.Children.Add(button); }