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


C# RadComboBox.SetBinding方法代码示例

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


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

示例1: OnApplyTemplate

        /// <summary>
        /// When overridden in a derived class, is invoked whenever application code or internal processes (such as a rebuilding layout pass) call <see cref="M:System.Windows.Controls.Control.ApplyTemplate"/>. In simplest terms, this means the method is called just before a UI element displays in an application. For more information, see Remarks.
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (_comboBox != null)
            {
                _comboBox.ClearValue(TagProperty);
                _comboBox.SelectionChanged -= OnSelectedFilterChanged;
                _comboBox = null;
            }

            if (_udpItemsControl != null)
            {
                _udpItemsControl.ItemsSource = null;
            }

            _comboBox = GetTemplateChild("FiltersComboBox") as RadComboBox;
            if (_comboBox != null)
            {
                _comboBox.DisplayMemberPath = ReflectionHelper.GetPropertyName<IFilter>(f => f.Name);
                _comboBox.SelectedValuePath = ReflectionHelper.GetPropertyName<IFilter>(f => f.FilterGuid);
                _comboBox.ItemsSource = FilterList;
                _comboBox.SelectedValue = FilterGuid;

                var expression = GetBindingExpression(FilterGuidProperty);
                if (expression != null && expression.ParentBinding != null)
                {
                    _comboBox.SetBinding(TagProperty, expression.ParentBinding);
                }

                _comboBox.SelectionChanged += OnSelectedFilterChanged;
            }

            _udpItemsControl = GetTemplateChild("UdpList") as ItemsControl;
            if (_udpItemsControl != null)
            {
                _udpItemsControl.ItemsSource = UdpList;
            }
        }
开发者ID:mparsin,项目名称:Elements,代码行数:42,代码来源:FilterSelector.cs

示例2: CreateColumn

        /// <summary>
        /// Creates the ImportDataGrid's import column.
        /// </summary>
        /// <param name="importColumn">The import column to setup a DataGridColumn for.</param>
        /// <param name="columnDisplayName">Display name of the column.</param>
        /// <returns></returns>
        private GridViewDataColumn CreateColumn(ImportColumn importColumn, string columnDisplayName)
        {
            #region Setup the import column header

            var columnHeaderColumnStackPanel = new StackPanel();

            var importColumnTypeComboBox = new RadComboBox { Width = 100, DisplayMemberPath = "DisplayName" };

            //TODO: Setup ComboBox's ItemTemplate to work with Multiplicity

            //Bind the ImportColumnTypeComboBox's itemsource to the import destination's column types
            importColumnTypeComboBox.SetBinding(ItemsControl.ItemsSourceProperty, new Binding("DestinationColumnTypes") { Source = VM.ImportData });

            //Bind the selected item of the ImportColumnTypeComboBox to the ImportColumn.ImportColumnType
            importColumnTypeComboBox.SetBinding(Selector.SelectedItemProperty, new Binding("ImportColumnType") { Mode = BindingMode.TwoWay, Source = importColumn });

            columnHeaderColumnStackPanel.Children.Add(importColumnTypeComboBox);
            columnHeaderColumnStackPanel.Children.Add(new TextBlock
            {
                Text = columnDisplayName,
                Foreground = new SolidColorBrush(Colors.White),
                HorizontalAlignment = HorizontalAlignment.Center
            });

            var columnHeaderStackPanel = new StackPanel { Orientation = Orientation.Horizontal };
            columnHeaderStackPanel.Children.Add(columnHeaderColumnStackPanel);
            var removeColumnButton = new Button
            {
                Content = "x",
                VerticalAlignment = VerticalAlignment.Center
            };

            columnHeaderStackPanel.Children.Add(removeColumnButton);

            #endregion

            var gridViewColumn = new GridViewDataColumn
            {
                UniqueName = importColumn.ColumnName,
                DataMemberBinding = new Binding(importColumn.ColumnName),
                //CellTemplate = (DataTemplate)this.Resources["DefaultCellTemplate"],
                //CellEditTemplate = (DataTemplate)this.Resources["DefaultEditTemplate"],
                Header = columnHeaderStackPanel
            };

            //When the remove column button is pressed, remove this column from the DataGrid.
            removeColumnButton.Click += (sender, args) => this.ImportRadGridView.Columns.Remove(gridViewColumn);

            //TODO: Dynamically add columns when all are selected. Wait on response from 
            //importColumnTypeComboBox.SelectionChanged += (sender, e) =>
            //{
            //    //Check if every column is selected
            //    var allAreSelected = true;
            //    foreach (var column in ImportRadGridView.Columns)
            //    {
            //        if (((StackPanel)column.Header).FindChildByType<RadComboBox>().SelectedItem == null)
            //            allAreSelected = false;
            //    }

            //    //Create another column if all columns are selected
            //    if (allAreSelected)
            //    {
            //        var newColumnUniqueName = String.Format("CustomColumn{0}", _customColumnIndex);
            //        var newColumn = VM.ImportData.AddColumn(newColumnUniqueName);
            //        ImportRadGridView.Columns.Add(CreateColumn(newColumn, ""));
            //        _customColumnIndex++;
            //    }
            //};

            return gridViewColumn;
        }
开发者ID:FoundOPS,项目名称:server,代码行数:77,代码来源:ImportDataGrid.xaml.cs


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