当前位置: 首页>>代码示例>>C#>>正文


C# ComboBox.SetBinding方法代码示例

本文整理汇总了C#中System.Windows.Controls.ComboBox.SetBinding方法的典型用法代码示例。如果您正苦于以下问题:C# ComboBox.SetBinding方法的具体用法?C# ComboBox.SetBinding怎么用?C# ComboBox.SetBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Controls.ComboBox的用法示例。


在下文中一共展示了ComboBox.SetBinding方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateComboBox

 protected virtual FrameworkElement CreateComboBox(PropertyItem pi, PropertyControlFactoryOptions options)
 {
     var cbox = new ComboBox() { IsEditable = true };
     cbox.SetBinding(Selector.SelectedItemProperty, new Binding(pi.Descriptor.Name + ".Text"));
     cbox.SetBinding(ItemsControl.ItemsSourceProperty, new Binding(pi.Descriptor.Name + ".Values"));
     return cbox;
 }
开发者ID:shuxingliu,项目名称:SambaPOS-3,代码行数:7,代码来源:PropertyControlFactory.cs

示例2: build_combo

        private StackPanel build_combo(string label_name, string prop_names, string selected_prop)
        {
            TextBlock tb_materials = new TextBlock();
            tb_materials.Text = label_name;
            tb_materials.TextAlignment = TextAlignment.Right;
            tb_materials.Width = 80;
            tb_materials.Height = 20;

            ComboBox cb_materials = new ComboBox();
            cb_materials.Width = 190;
            cb_materials.Height = 20;
            cb_materials.Foreground = Brushes.White;
            Binding bind = new Binding(prop_names);
            cb_materials.SetBinding(ComboBox.ItemsSourceProperty, bind);

            Binding bind2 = new Binding(selected_prop);
            cb_materials.SetBinding(ComboBox.SelectedItemProperty, bind2);

            StackPanel sp_materials = new StackPanel();
            sp_materials.Orientation = Orientation.Horizontal;
            sp_materials.Height = 25;
            sp_materials.Children.Add(tb_materials);
            sp_materials.Children.Add(cb_materials);
            return sp_materials;
        }
开发者ID:mario007,项目名称:renmas,代码行数:25,代码来源:MaterialEditor.xaml.cs

示例3: build_gui

        private void build_gui()
        {
            this.DataContext = shapes;

            TextBlock tb_shapes = new TextBlock();
            tb_shapes.Text = " Shapes: ";
            tb_shapes.Width = 60;
            tb_shapes.Height = 20;

            ComboBox cb = new ComboBox();
            cb.Width = 210;
            cb.Height = 20;
            cb.Foreground = Brushes.White;
            Binding bind = new Binding("ShapeNames");
            cb.SetBinding(ComboBox.ItemsSourceProperty, bind);

            Binding bind2 = new Binding("SelectedShape");
            cb.SetBinding(ComboBox.SelectedItemProperty, bind2);

            StackPanel sp = new StackPanel();
            sp.Orientation = Orientation.Horizontal;
            sp.Height = 25;
            sp.Children.Add(tb_shapes);
            sp.Children.Add(cb);

            TextBlock tb_materials = new TextBlock();
            tb_materials.Text = " Materials: ";
            tb_materials.Width = 60;
            ComboBox cb_mat = new ComboBox();
            cb_mat.Width = 210;
            cb_mat.Height = 20;
            cb_mat.Foreground = Brushes.White;

            Binding bind3 = new Binding("MaterialNames");
            cb_mat.SetBinding(ComboBox.ItemsSourceProperty, bind3);
            Binding bind4 = new Binding("SelectedMaterial");
            cb_mat.SetBinding(ComboBox.SelectedItemProperty, bind4);

            StackPanel sp_mat = new StackPanel();
            sp_mat.Orientation = Orientation.Horizontal;
            sp_mat.Children.Add(tb_materials);
            sp_mat.Children.Add(cb_mat);

            StackPanel all = new StackPanel();
            all.Children.Add(sp);
            all.Children.Add(sp_mat);

            Expander expander = new Expander();
            expander.Header = " Shapes";
            expander.Foreground = Brushes.White;
            expander.Content = all;
            this.Content = expander;
        }
开发者ID:mario007,项目名称:renmas,代码行数:53,代码来源:Shapes_editor.xaml.cs

示例4: build_gui

        private void build_gui()
        {
            this.DataContext = tm_operators;

            TextBlock tb_operators = new TextBlock();
            tb_operators.Text = " Operators: ";
            tb_operators.Width = 60;
            tb_operators.Height = 20;

            ComboBox cb = new ComboBox();
            cb.Width = 210;
            cb.Height = 20;
            cb.Foreground = Brushes.White;
            Binding bind = new Binding("OperatorNames");
            cb.SetBinding(ComboBox.ItemsSourceProperty, bind);

            Binding bind2 = new Binding("SelectedOperator");
            cb.SetBinding(ComboBox.SelectedItemProperty, bind2);

            StackPanel sp = new StackPanel();
            sp.Orientation = Orientation.Horizontal;
            sp.Height = 25;
            sp.Children.Add(tb_operators);
            sp.Children.Add(cb);

            StackPanel tonemap_sp = this.build_lblcb(" Tone Mapping: ", "ToneMapping");

            StackPanel sp_operator = new StackPanel();
            if (tm_operators.SelectedOperator == "Reinhard")
            {
                this.build_reinhard(sp_operator);
            }
            else if (tm_operators.SelectedOperator == "Photoreceptor")
            {
                this.build_photoreceptor(sp_operator);
            }
            else
            {
            }

            StackPanel all = new StackPanel();
            all.Children.Add(tonemap_sp);
            all.Children.Add(sp);
            all.Children.Add(sp_operator);

            Expander expander = new Expander();
            expander.Header = " Tone mapping";
            expander.Foreground = Brushes.White;
            expander.Content = all;
            this.Content = expander;
        }
开发者ID:mario007,项目名称:renmas,代码行数:51,代码来源:ToneMappingEditor.xaml.cs

示例5: GenerateUiElement

        public override FrameworkElement GenerateUiElement(string Key, ArmA_UI_Editor.UI.Snaps.EditingSnap window, PTypeDataTag tag)
        {
            var cb = new ComboBox();
            cb.Tag = tag;
            cb.DisplayMemberPath = "Name";
            cb.SelectedValuePath = "Value";
            cb.ItemsSource = this.Items;

            var binding = new Binding("Value");
            binding.Source = AddInManager.Instance.MainFile;
            binding.NotifyOnSourceUpdated = true;

            if (tag.PropertyObject is SqfProperty)
            {
                binding.Converter = new SqfPropertyConverter(Key, tag, this.Items);
                binding.ConverterParameter = tag;
            }
            else
            {
                binding.Converter = new NormalPropertyConverter(Key, this.Items);
            }
            cb.SetBinding(ComboBox.SelectedIndexProperty, binding);
            cb.SourceUpdated += Cb_SourceUpdated;
            cb.ToolTip = App.Current.Resources["STR_CODE_Property_ValueList"] as String;
            return cb;
        }
开发者ID:X39,项目名称:ArmA-UI-Editor,代码行数:26,代码来源:ListboxType.cs

示例6: GenerateFormItems

        private async void GenerateFormItems()
        {
            if (_labels == null)
            {
                _labels = await _labelGenerator.FetchAllLabelTemplates();
            }

            if (_labels.HasContent())
            {
                StackPanel stackPanel;
                foreach (var label in _labels)
                {
                    stackPanel = new StackPanel { Orientation = Orientation.Horizontal };
                    stackPanel.Children.Add(new Label { Content = label.FriendlyName });



                    var comboBox = new ComboBox {Name = label.Name};

                    comboBox.SetBinding(
                       ItemsControl.ItemsSourceProperty,
                       new Binding { Source = GetInstalledPrinters() });

                    comboBox.SelectedValue = label.Printer;

                    comboBox.SetBinding(
                       Selector.SelectedItemProperty,
                       new Binding("Printer") { Source = label, Mode = BindingMode.TwoWay });

                    stackPanel.Children.Add(comboBox);

                    SpLabels.Children.Add(stackPanel);
                }

                stackPanel = new StackPanel { Orientation = Orientation.Horizontal };

                var saveButton = new Button { Name = "Save", Content = "Save" };
                saveButton.Click += SaveButtonOnClick;
                stackPanel.Children.Add(saveButton);

                SpLabels.Children.Add(stackPanel);
            }

        }
开发者ID:christopherwithers,项目名称:LabelPrinter,代码行数:44,代码来源:Labels.xaml.cs

示例7: GenerateEditingElement

        protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem)
        {
            var editElement = new ComboBox();
            editElement.SetBinding(Selector.SelectedItemProperty, Binding);

            var prop = dataItem.GetType().GetProperty(Binding.Path.Path,
                BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public);
            Utilities.FillEnums(editElement, prop.PropertyType);
            return editElement;
        }
开发者ID:yan122725529,项目名称:TripRobot.Crawler,代码行数:10,代码来源:DataGridColumns.cs

示例8: CreateView

        public FrameworkElement CreateView(PropertyInfo property)
        {
            var inputControl = new ComboBox();
            var enumtype = property.PropertyType;

            inputControl.ItemsSource = GetNameList(enumtype);
            var binding = new Binding(property.Name);
            binding.Mode = BindingMode.TwoWay;
            inputControl.SetBinding(ComboBox.SelectedItemProperty, binding);

            return inputControl;
        }
开发者ID:zealoussnow,项目名称:OneCode,代码行数:12,代码来源:EnumConfigControl.cs

示例9: ComboBoxEditor

        public ComboBoxEditor(WorkFrame frame, object[] items)
            : base(frame)
        {
            ComboBox comboBox = new ComboBox();
            comboBox.DataContext = this;
            comboBox.ItemsSource = items;
            var binding = new Binding("Value");
            binding.Mode = BindingMode.TwoWay;
            comboBox.SetBinding(ComboBox.SelectedItemProperty, binding);

            Content = comboBox;
        }
开发者ID:liny4cn,项目名称:ComBoost,代码行数:12,代码来源:ComboBoxEditor.cs

示例10: SetSignalTowerBinding

        private void SetSignalTowerBinding(SignalTowerConfig config, ComboBox red, ComboBox buzzer)
        {
            Binding bd = new Binding("RedLamp");
            bd.Source = config;
            bd.Mode = BindingMode.TwoWay;
            red.SetBinding(ComboBox.SelectedIndexProperty, bd);

            bd = new Binding("Buzzer");
            bd.Source = config;
            bd.Mode = BindingMode.TwoWay;
            buzzer.SetBinding(ComboBox.SelectedIndexProperty, bd);
        }
开发者ID:vesteksoftware,项目名称:VT5021,代码行数:12,代码来源:PageSignalTowerSetting.xaml.cs

示例11: LoadUI

        public override FrameworkElement LoadUI(Option option)
        {
            var box = new ComboBox
            {
                MinWidth = 100,
                DataContext = this,
                ItemsSource = Items
            };

            box.SetBinding(Selector.SelectedItemProperty, new Binding(nameof(CurrentItem)));

            return box;
        }
开发者ID:Tauron1990,项目名称:Radio-Streamer,代码行数:13,代码来源:ComboboxHelper.cs

示例12: DataBind

        public void DataBind(ComboBox lbl, string properySourcePath, string selectedValuePath, Hashtable propertyBag)
        {
            //binding the list
            string key = properySourcePath.Split('.')[0];
            lbl.ItemsSource = (IEnumerable)propertyBag[key];

            //binding selected value
            key = selectedValuePath.Split('.')[0];
            string path = selectedValuePath.Replace(key + ".", "");
            Binding selectedValue = new Binding(path);
            selectedValue.Source = propertyBag[key];
            lbl.SetBinding(ComboBox.SelectedItemProperty, selectedValue);
        }
开发者ID:CraigCary,项目名称:roduino,代码行数:13,代码来源:DataBindingUtil.cs

示例13: LoadUI

        public FrameworkElement LoadUI(Option option)
        {
            var box = new ComboBox
            {
                MinWidth = 100,
                DataContext = this,
                ItemsSource = Profiles
            };

            box.SetBinding(Selector.SelectedItemProperty, new Binding("CurrentEncoder"));

            return box;
        }
开发者ID:Tauron1990,项目名称:Radio-Streamer,代码行数:13,代码来源:DefaultProfileHelper.cs

示例14: build_gui

        public void build_gui()
        {
            this.DataContext = lights;

            TextBlock tb_lights = new TextBlock();
            tb_lights.Text = " Lights: ";
            ComboBox cb = new ComboBox();
            cb.Width = 150;
            cb.Foreground = Brushes.White;
            Binding bind = new Binding("LightNames");
            cb.SetBinding(ComboBox.ItemsSourceProperty, bind);

            Binding bind2 = new Binding("SelectedLight");
            cb.SetBinding(ComboBox.SelectedItemProperty, bind2);

            StackPanel sp = new StackPanel();
            sp.Orientation = Orientation.Horizontal;
            sp.Children.Add(tb_lights);
            sp.Children.Add(cb);

            StackPanel all = new StackPanel();
            all.Children.Add(sp);
            if (this.lights.SelectedLight != "")
            {
                if (this.lights.LightType == "PointLight")
                {
                    this.build_point_light(all);
                }
            }

            Expander expander = new Expander();
            expander.Header = "Lights";
            expander.Foreground = Brushes.White;
            expander.Content = all;
            this.Content = expander;
        }
开发者ID:mario007,项目名称:renmas,代码行数:36,代码来源:LightsEditor.xaml.cs

示例15: CreateControlForLookup

        public FrameworkElement CreateControlForLookup(FormItemContext context, List<NameValuePair> options)
        {
            ComboBox cb = new ComboBox();
            cb.ItemsSource = options;
            cb.SelectedValuePath = "Value";

            var binding = new Binding(context.PropertyInfo.Name)
            {
                Mode = BindingMode.TwoWay,
            };
            binding.ValidationRules.Add(new AnnotationValidationRule(context.PropertyInfo));
            cb.SetBinding(ComboBox.SelectedValueProperty, binding);
            CustomValidation.SetValidationProperty(cb, ComboBox.SelectedValueProperty);
            StyleHelper.ApplyStyle(cb, FormControlConstrants.EDIT_COMBO_STYLE);
            return cb;
        }
开发者ID:mogliang,项目名称:Generic-WPF-Form-Controls,代码行数:16,代码来源:ComboBoxSink.cs


注:本文中的System.Windows.Controls.ComboBox.SetBinding方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。