private ComboBoxEditableWhenFocused CreateCardinalityComboBox(object businessObject, string bindingPropertyName, string isVisiblePropetyName, string isEnabledPropertyName) { var comboBox = new ComboBoxEditableWhenFocused { Style = (Style)FindResource(COMBOBOX_STYLE), ItemsSource = CardinalityList.Instance, DisplayMemberPath = "Text", SelectedValuePath = "Value" }; SetCommunBindings(comboBox, ComboBoxEditableWhenFocused.SelectedValueProperty, businessObject, bindingPropertyName, isVisiblePropetyName); if (isEnabledPropertyName != null) { comboBox.SetBinding(ComboBoxEditableWhenFocused.IsReadOnlyProperty, new Binding(isEnabledPropertyName) { Source = businessObject, Converter = new NotBoolConverter() }); } return(comboBox); }
private ComboBoxEditableWhenFocused CreateComboBoxWithNull <T>(object businessObject, IEnumerable <T> items, string displayMemberPath, string bindingPropertyName, string isVisiblePropetyName, string isEnabledPropertyName) where T : class { var style = (Style)FindResource(COMBOBOX_STYLE); var comboBox = new ComboBoxEditableWhenFocused(); var itemType = items.GetType(); var nullValues = NullValue.GetValues("(none)"); comboBox.ItemsSource = new CompositeCollection() { new CollectionContainer() { Collection = nullValues }, new CollectionContainer() { Collection = items } }; var newStyle = new Style(typeof(ComboBoxEditableWhenFocused)); var fef = new FrameworkElementFactory(typeof(TextBlock)); fef.SetBinding(TextBlock.TextProperty, new Binding(displayMemberPath)); var styleResourceDictionary = new ResourceDictionary(); foreach (var trigger in style.Triggers) { newStyle.Triggers.Add(trigger); } foreach (var resourceKey in style.Resources.Keys) { styleResourceDictionary.Add(resourceKey, style.Resources[resourceKey]); } styleResourceDictionary.Add(itemType.GetGenericArguments()[0], new DataTemplate(itemType.GetGenericArguments()[0]) { VisualTree = fef }); newStyle.Resources = styleResourceDictionary; comboBox.Style = newStyle; SetCommunBindings(comboBox, ComboBoxEditableWhenFocused.SelectedValueProperty, new ComboBoxSelectedValueBindingWithNull <T>(businessObject.GetType().GetProperty(bindingPropertyName).GetValue(businessObject, null) ?? nullValues[0], (T value) => businessObject.GetType().GetProperty(bindingPropertyName).SetValue(businessObject, value, null)), "ComboSelectedValue", isVisiblePropetyName); if (isEnabledPropertyName != null) { comboBox.SetBinding(ComboBoxEditableWhenFocused.IsReadOnlyProperty, new Binding(isEnabledPropertyName) { Source = businessObject, Converter = new NotBoolConverter() }); } return(comboBox); }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.propertyComboBox = ((ICSharpCode.Data.EDMDesigner.Core.UI.UserControls.ComboBoxEditableWhenFocused)(target)); return; case 2: this.propertyNullValues = ((System.Windows.Data.CollectionContainer)(target)); return; case 3: this.properties = ((System.Windows.Data.CollectionContainer)(target)); return; } this._contentLoaded = true; }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.tablesComboBox = ((ICSharpCode.Data.EDMDesigner.Core.UI.UserControls.ComboBoxEditableWhenFocused)(target)); return; case 2: this.tableMappingTreeView = ((System.Windows.Controls.TreeView)(target)); return; case 3: this.conditionsTreeViewItem = ((ICSharpCode.Data.EDMDesigner.Core.UI.UserControls.Mapping.TreeViewItemMapping)(target)); return; case 4: this.columnConditionsGrid = ((System.Windows.Controls.DataGrid)(target)); return; case 5: this.addColumnConditionButton = ((System.Windows.Controls.Button)(target)); #line 55 "..\..\..\..\UserControls\Mapping\AssociationMapping.xaml" this.addColumnConditionButton.Click += new System.Windows.RoutedEventHandler(this.AddColumnConditionButton_Click); #line default #line hidden return; case 6: this.propertiesMappingNavigationProperty1 = ((ICSharpCode.Data.EDMDesigner.Core.UI.UserControls.Mapping.PropertiesMapping)(target)); return; case 7: this.propertiesMappingNavigationProperty2 = ((ICSharpCode.Data.EDMDesigner.Core.UI.UserControls.Mapping.PropertiesMapping)(target)); return; } this._contentLoaded = true; }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.tablesComboBox = ((ICSharpCode.Data.EDMDesigner.Core.UI.UserControls.ComboBoxEditableWhenFocused)(target)); return; case 2: this.tableNullValues = ((System.Windows.Data.CollectionContainer)(target)); return; case 3: this.tablesValues = ((System.Windows.Data.CollectionContainer)(target)); return; case 4: this.hesCheckBox = ((System.Windows.Controls.CheckBox)(target)); return; case 5: this.tableMappingTreeView = ((System.Windows.Controls.TreeView)(target)); return; case 6: this.conditionsTreeViewItem = ((ICSharpCode.Data.EDMDesigner.Core.UI.UserControls.Mapping.TreeViewItemMapping)(target)); return; case 7: this.columnConditionsTreeViewItem = ((ICSharpCode.Data.EDMDesigner.Core.UI.UserControls.Mapping.TreeViewItemMapping)(target)); return; case 8: this.columnConditionsGrid = ((System.Windows.Controls.DataGrid)(target)); return; case 9: this.addColumnConditionButton = ((System.Windows.Controls.Button)(target)); #line 75 "..\..\..\..\UserControls\Mapping\EntityTableMapping.xaml" this.addColumnConditionButton.Click += new System.Windows.RoutedEventHandler(this.AddColumnConditionButton_Click); #line default #line hidden return; case 10: this.propertyConditionsTreeViewItem = ((ICSharpCode.Data.EDMDesigner.Core.UI.UserControls.Mapping.TreeViewItemMapping)(target)); return; case 11: this.propertyConditionsGrid = ((System.Windows.Controls.DataGrid)(target)); return; case 12: this.addPropertyConditionButton = ((System.Windows.Controls.Button)(target)); #line 105 "..\..\..\..\UserControls\Mapping\EntityTableMapping.xaml" this.addPropertyConditionButton.Click += new System.Windows.RoutedEventHandler(this.AddPropertyConditionButton_Click); #line default #line hidden return; case 13: this.propertiesTreeViewItem = ((ICSharpCode.Data.EDMDesigner.Core.UI.UserControls.Mapping.TreeViewItemMapping)(target)); return; case 14: this.propertiesMappingControl = ((ICSharpCode.Data.EDMDesigner.Core.UI.UserControls.Mapping.EntityPropertiesMapping)(target)); return; case 15: this.complexPropertiesMappingControl = ((ICSharpCode.Data.EDMDesigner.Core.UI.UserControls.Mapping.ComplexPropertiesMapping)(target)); return; } this._contentLoaded = true; }