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


C# ComboBox.SetValue方法代码示例

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


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

示例1: AddNewPanel

 public Panel AddNewPanel()
 {
     ListView newLV = new ListView();
     ComboBox newCB = new ComboBox();
     panels.Add(new Panel(newCB, newLV));
     newLV.Style = Resources["PanelListView"] as Style;
     newLV.ItemContainerStyle = Resources["PanelListViewItem"] as Style; ;
     GridView columns = new GridView();
     columns.Columns.Add(AddGridViewColumn( "Name", "Name"));
     columns.Columns.Add(AddGridViewColumn( "Type", "Extension"));
     columns.Columns.Add(AddGridViewColumn( "Size", "Length"));
     columns.Columns.Add(AddGridViewColumn( "Date of creation", "CreationTime"));
     newLV.View = columns;
     newLV.Loaded += PanelInitialized;
     newCB.Style = Resources["DrivesComboBox"] as Style;
     ColumnDefinition newColumn = new ColumnDefinition();
     newColumn.Width = new GridLength(1, GridUnitType.Star);
     PanelsGrid.ColumnDefinitions.Add(newColumn);
     newLV.SetValue(Grid.RowProperty, 1);
     newLV.SetValue(Grid.ColumnProperty, numOfPanels);
     newCB.SetValue(Grid.RowProperty, 0);
     newCB.SetValue(Grid.ColumnProperty, numOfPanels);
     PanelsGrid.Children.Add(newLV);
     PanelsGrid.Children.Add(newCB);
     AddDrivesInComboBox(newCB);
     newCB.SelectionChanged += DiskChanged;
     return panels[numOfPanels++];
 }
开发者ID:pseudowolfvn,项目名称:FileManager,代码行数:28,代码来源:MainWindow.xaml.cs

示例2: SetUp

        public void SetUp()
        {
            _comboBox = new ComboBox();
            _comboBox.SetValue(UndoManager.UndoScopeNameProperty, "ScopeName");
            _fakeVm = new FakeVm();
            var selected = new Binding("SelectedEnum")
            {
                Source = _fakeVm,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit,
                NotifyOnSourceUpdated = true,
                NotifyOnTargetUpdated = true,
                Mode = BindingMode.TwoWay
            };
            BindingOperations.SetBinding(_comboBox, Selector.SelectedItemProperty, selected);

            var itemsSource = new Binding("EnumValues")
            {
                Source = _fakeVm,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit,
                NotifyOnSourceUpdated = true,
                NotifyOnTargetUpdated = true,
                Mode = BindingMode.OneWay
            };
            BindingOperations.SetBinding(_comboBox, ItemsControl.ItemsSourceProperty, itemsSource);
            _comboBox.DataContext = _fakeVm;
            _undoManager = UndoManager.GetUndoManager(_comboBox);
        }
开发者ID:JohanLarsson,项目名称:UndoRedo,代码行数:27,代码来源:ComboBoxTests.cs

示例3: GetOrCreateBehavior

        private static ComboBoxKeyCommandBehavior GetOrCreateBehavior(ComboBox comboBox)
        {
            var behavior = comboBox.GetValue(ComboBoxKeyCommandBehaviorProperty) as ComboBoxKeyCommandBehavior;
            if (behavior == null)
            {
                behavior = new ComboBoxKeyCommandBehavior(comboBox);
                comboBox.SetValue(ComboBoxKeyCommandBehaviorProperty, behavior);
            }

            return behavior;
        }
开发者ID:JohnDMathis,项目名称:Pippin,代码行数:11,代码来源:ComboBoxKey.cs

示例4: TestGrid

 public TestGrid(ComboBox comboBox, ITestPage testPage) {
     TestPage = testPage;
     RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
     RowDefinitions.Add(new RowDefinition());
     if(comboBox != null) {
         Children.Add(comboBox);
         comboBox.SetValue(Grid.RowProperty, 0);
     }
     Children.Add((UIElement)testPage);
     ((UIElement)testPage).SetValue(Grid.RowProperty, 1);
 }
开发者ID:JustGitHubUser,项目名称:DevExpress.Mvvm.Free,代码行数:11,代码来源:TestGrid.cs

示例5: AddListView

        public void AddListView(IEnumerable<Core.Fragment> ie, int colIndex)
        {
            if (mainGrid != null)
            {
                ListView lv = new ListView();
                lv.SetValue(Grid.ColumnProperty, colIndex);
                lv.SetValue(Grid.RowProperty, 1);

                ComboBox cmb = new ComboBox();
                cmb.SetValue(Grid.ColumnProperty, colIndex);
                cmb.SetValue(Grid.RowProperty, 0);
                cmb.SelectionChanged += Cmb_SelectionChanged;
                Associate(lv, cmb);

                mainGrid.Children.Add(cmb);
                mainGrid.Children.Add(lv);

                lv.ItemsSource = ie;
                listViews.Insert(colIndex, lv);
                RefreshMetaKeys(cmb, lv);
                lv.UpdateLayout();
            }
        }
开发者ID:BBuchholz,项目名称:NineWorldsDeep,代码行数:23,代码来源:WorkbenchListViewsController.cs

示例6: btnOK_Click

        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            try
            {
            cnvOptions.Children.Clear();
            lsttxt.Clear();
            lstActionQue.Clear();
            int number = 0;
            if(txtNoOfOptions.Text.Trim() !="")
            number = Int16.Parse(txtNoOfOptions.Text.Trim());

            for (int i = 0; i < number; i++)
            {
                Label lbl = new Label();
                lbl.Height = 23;
                lbl.Width = 70;
                lbl.Content = "Option " + (i+1).ToString();
                lbl.SetValue(Canvas.LeftProperty, 20.0);
                lbl.SetValue(Canvas.TopProperty, 10 + (25.0 * i));
                cnvOptions.Children.Add(lbl);

                TextBox txt = new TextBox();
                txt.Height = 23;
                txt.Width = 600;
                txt.SetValue(Canvas.LeftProperty, 100.0);
                txt.SetValue(Canvas.TopProperty, 10 + (25.0 * i));
                lsttxt.Add(txt);
                cnvOptions.Children.Add(txt);

                ComboBox cmb = new ComboBox();
                cmb.Height = 23;
                cmb.Width = 300;

                for (int i1 = 0; i1 < lstQuestions.Count; i1++)
                {
                    ComboBoxItem cbi = new ComboBoxItem();
                    cbi.Content = lstQuestions[i1].Header;
                    cbi.Tag = i1.ToString();
                    cmb.Items.Add(cbi);
                }

                cmb.SetValue(Canvas.LeftProperty, 710.0);
                cmb.SetValue(Canvas.TopProperty, 10 + (25.0 * i));
                lstActionQue.Add(cmb);
                //lsttxt.Add(txt);
                cnvOptions.Children.Add(cmb);
                
            }
            }
            catch (Exception exp)
            {
                VMuktiAPI.VMuktiHelper.ExceptionHandler(exp, "btnOK_Click()", "ctlQuestion.xaml.cs");
            }
        }
开发者ID:jiangguang5201314,项目名称:VMukti,代码行数:54,代码来源:ctlQuestion.xaml.cs

示例7: AddUI

        public override void AddUI(Grid grid)
        {
            if (Config != null && Config.ShownAtRunTime)
            {
                #region
                StackPanel panel = new StackPanel()
                {
                    Orientation = System.Windows.Controls.Orientation.Horizontal,
                    HorizontalAlignment = System.Windows.HorizontalAlignment.Left
                };
                TextBox tb = new TextBox() { Margin = new Thickness(2), Width = 50 };
                tb.SetValue(Grid.ColumnProperty, 0);
                tb.SetValue(ToolTipService.ToolTipProperty, Config.ToolTip);
               if (value != null)
                    tb.Text = value.Distance.ToString();
               tb.TextChanged += (s, e) =>
               {
                   double val = double.NaN;
                   if (double.TryParse(tb.Text, System.Globalization.NumberStyles.Any, CultureHelper.GetCurrentCulture(), out val))
                   {
                       if (value == null)
                           Value = new GPLinearUnit(Config.Name, esriUnits.esriUnknownUnits, val);
                       else
                           value.Distance = val;
                   }
                   else
                   {
                       if (value == null)
                           Value = new GPLinearUnit(Config.Name, esriUnits.esriUnknownUnits, double.NaN);
                       else
                           value.Distance = double.NaN;
                   }
                   RaiseCanExecuteChanged();
               };
               panel.Children.Add(tb);

               ComboBox cb = new ComboBox()
               {
                   HorizontalAlignment = System.Windows.HorizontalAlignment.Left,
                   Width = 125,
                   Height = 24,
                   Margin = new Thickness(2),
                   Foreground = new SolidColorBrush(Colors.Black)
               };
                cb.SetValue(Grid.ColumnProperty, 1);
                cb.Items.Add(new TextBlock() { Text = Strings.Unknown, Tag = esriUnits.esriUnknownUnits});
                cb.Items.Add(new TextBlock() { Text = Strings.Inches, Tag = esriUnits.esriInches });
                cb.Items.Add(new TextBlock() { Text = Strings.Points, Tag = esriUnits.esriPoints });
                cb.Items.Add(new TextBlock() { Text = Strings.Feet, Tag = esriUnits.esriFeet });
                cb.Items.Add(new TextBlock() { Text = Strings.Yards, Tag = esriUnits.esriYards });
                cb.Items.Add(new TextBlock() { Text = Strings.Miles, Tag = esriUnits.esriMiles });
                cb.Items.Add(new TextBlock() { Text = Strings.NauticalMiles, Tag = esriUnits.esriNauticalMiles });
                cb.Items.Add(new TextBlock() { Text = Strings.Millimeters, Tag = esriUnits.esriMillimeters });
                cb.Items.Add(new TextBlock() { Text = Strings.Centimeters, Tag = esriUnits.esriCentimeters });
                cb.Items.Add(new TextBlock() { Text = Strings.Meters, Tag = esriUnits.esriMeters });
                cb.Items.Add(new TextBlock() { Text = Strings.Kilometers, Tag = esriUnits.esriKilometers });
                cb.Items.Add(new TextBlock() { Text = Strings.DecimalDegrees, Tag = esriUnits.esriDecimalDegrees });
                cb.Items.Add(new TextBlock() { Text = Strings.Decimeters, Tag = esriUnits.esriDecimeters });

                TextBlock item;                
                for (int i = 0; i < cb.Items.Count; i++)
                {
                    item = cb.Items[i] as TextBlock;
                    if (((esriUnits)item.Tag) == value.Unit)
                    {
                        cb.SelectedIndex = i;
                        cb.SelectedItem = item;
                    }
                }
                cb.SelectionChanged += (a, b) =>
                    {
                        value.Unit = (esriUnits)((cb.SelectedItem as TextBlock).Tag);
                        RaiseCanExecuteChanged();
                    };
                panel.Children.Add(cb);
                panel.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
                panel.SetValue(Grid.ColumnProperty, 1);
                grid.Children.Add(panel);
                #endregion
                RaiseCanExecuteChanged();
            }
        }
开发者ID:Esri,项目名称:arcgis-viewer-silverlight,代码行数:82,代码来源:LinearUnitParameter.cs

示例8: cnvPaint_Drop

        void cnvPaint_Drop(object sender, DragEventArgs e)
        {
            try
            {
                if (e.Data.GetData(typeof(Button)) != null)
                {
                    if (((Canvas)((Button)e.Data.GetData(typeof(Button))).Parent).Name.ToString() == "cnvControls")
                    {

                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        Button btn = new Button();
                        btn.Height = 25;
                        btn.Width = 100;
                        btn.Content = "Button";
                        btn.PreviewMouseDown += new MouseButtonEventHandler(btnDrag_PreviewMouseDown);
                        btn.SetValue(Canvas.LeftProperty, 10.0);
                        btn.SetValue(Canvas.TopProperty, 10.0);

                        ctlPOD objPOD = new ctlPOD();
                        objPOD.AllowDrop = true;
                        objPOD.Height = 25;
                        objPOD.Width = 100;
                        objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                        objPOD.SetValue(Canvas.LeftProperty, p.X);
                        objPOD.SetValue(Canvas.TopProperty, p.Y);
                        MyPropGrid.ControlToBind = objPOD;
                        objPOD.cnvPOD.Children.Add(btn);
                        currentControl = objPOD;
                        cnvPaint.Children.Add(objPOD);
                    }
                    else if ((((Canvas)((Button)e.Data.GetData(typeof(Button))).Parent).Parent).GetType() == typeof(ctlPOD))
                    {
                        if (currentControl.rect.Visibility == Visibility.Visible)
                        {
                            Point p = e.GetPosition((IInputElement)cnvPaint);
                            ((Canvas)((Button)e.Data.GetData(typeof(Button))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                            ((Canvas)((Button)e.Data.GetData(typeof(Button))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);
                        }
                    }
                }
                else if (e.Data.GetData(typeof(TabControl)) != null)
                {
                    if (((Canvas)((TabControl)e.Data.GetData(typeof(TabControl))).Parent).Name.ToString() == "cnvControls")
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        TabControl lbl = new TabControl();
                        //lbl.Content = "TabControl";
                        lbl.HorizontalContentAlignment = HorizontalAlignment.Center;
                        lbl.Height = 25;
                        lbl.Width = 100;
                        lbl.PreviewMouseDown += new MouseButtonEventHandler(tabDrag999_PreviewMouseDown);
                        lbl.SetValue(Canvas.LeftProperty, 10.0);
                        lbl.SetValue(Canvas.TopProperty, 10.0);

                        ctlPOD objPOD = new ctlPOD();
                        objPOD.cnvPOD.Children.Add(lbl);
                        objPOD.AllowDrop = true;
                        objPOD.Height = 25;
                        objPOD.Width = 100;
                        objPOD.SetValue(Canvas.LeftProperty, p.X);
                        objPOD.SetValue(Canvas.TopProperty, p.Y);
                        MyPropGrid.ControlToBind = objPOD;
                        objPOD.KeyDown += new KeyEventHandler(objPOD_KeyDown);
                        objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                        currentControl = objPOD;
                        cnvPaint.Children.Add(objPOD);
                    }

                    else if ((((Canvas)((TabControl)e.Data.GetData(typeof(TabControl))).Parent).Parent).GetType() == typeof(ctlPOD))
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ((Canvas)((TabControl)e.Data.GetData(typeof(TabControl))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                        ((Canvas)((TabControl)e.Data.GetData(typeof(TabControl))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);

                    }

                }
                else if (e.Data.GetData(typeof(Label)) != null)
                {
                    if (((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Name.ToString() == "cnvControls")
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        Label lbl = new Label();
                        lbl.Content = "Label";
                        lbl.HorizontalContentAlignment = HorizontalAlignment.Center;
                        lbl.Height = 25;
                        lbl.Width = 100;
                        lbl.PreviewMouseDown += new MouseButtonEventHandler(lblDrag_PreviewMouseDown);
                        lbl.SetValue(Canvas.LeftProperty, 10.0);
                        lbl.SetValue(Canvas.TopProperty, 10.0);

                        ctlPOD objPOD = new ctlPOD();
                        objPOD.cnvPOD.Children.Add(lbl);
                        objPOD.AllowDrop = true;
                        objPOD.Height = 25;
                        objPOD.Width = 100;
                        objPOD.SetValue(Canvas.LeftProperty, p.X);
                        objPOD.SetValue(Canvas.TopProperty, p.Y);
                        MyPropGrid.ControlToBind = objPOD;
                        objPOD.KeyDown += new KeyEventHandler(objPOD_KeyDown);
//.........这里部分代码省略.........
开发者ID:jiangguang5201314,项目名称:VMukti,代码行数:101,代码来源:ctlCRMDesigner.xaml.cs

示例9: populateLayerPanel

        private void populateLayerPanel(List<GraphicsLayer> inputLayers)
        {
            layerPanel.Children.Clear();
            if (inputLayers.Count > 0)
            {
                cb = new ComboBox()
                    {
                        HorizontalAlignment = System.Windows.HorizontalAlignment.Left,
                        Width = 125,
                        Height = 24,
                        Foreground = new SolidColorBrush(Colors.Black)
                    };
                populateLayerList(inputLayers);
                cb.SetValue(Grid.ColumnProperty, 1);
                cb.SelectionChanged += (a, b) =>
                {
                    GraphicsLayer selLayer = cb.SelectedItem as GraphicsLayer;
                    if (selLayer != null)
                    {
                        InputLayerID = selLayer.ID;
                        FeatureSet features = new FeatureSet();
                        FeatureSet selectedFeatures = new FeatureSet();

                        foreach (Graphic g in selLayer.Graphics)
                        {
                            if (g.Geometry != null)
                            {
                                if (features.SpatialReference == null)
                                    features.SpatialReference = g.Geometry.SpatialReference;
                                Graphic newG = new Graphic();
                                newG.Geometry = g.Geometry;
                                features.Features.Add(newG);
                                if (g.Selected)
                                    selectedFeatures.Features.Add(newG);
                            }
                        }
                        if (selectedFeatures.Features.Count > 0)
                            Value = new GPFeatureRecordSetLayer(Config.Name, selectedFeatures);
                        else
                            Value = new GPFeatureRecordSetLayer(Config.Name, features);
                    }
                    else
                        Value = null;
                    RaiseCanExecuteChanged();

                };
                layerPanel.Children.Add(cb);
                RaiseCanExecuteChanged();
            }
            else
            {
                TextBlock tb = new TextBlock() { Text = string.Format(Resources.Strings.NoLayersAvailable, getGeometryType()) };
                ToolTipService.SetToolTip(tb, string.Format(Resources.Strings.AddLayersToMap, getGeometryType()));
                layerPanel.Children.Add(tb);
                RaiseCanExecuteChanged();
            }
        }
开发者ID:yulifengwx,项目名称:arcgis-viewer-silverlight,代码行数:57,代码来源:SelectExistingLayerParameter.cs

示例10: Init

        void Init()
        {
            #region Setup type lookup dropdowns
            // Create a grid which is located at the very top of the editor document
            var stk = new Grid()
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                Height = 24,
                VerticalAlignment = VerticalAlignment.Top
            };

            // Give it two columns that have an equal width
            stk.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(0.5, GridUnitType.Star) });
            stk.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(0.5, GridUnitType.Star) });

            // Move the editor away from the upper boundary
            Editor.Margin = new Thickness() { Top = stk.Height };

            MainEditorContainer.Children.Add(stk);

            lookup_Types = new ComboBox() { HorizontalAlignment = HorizontalAlignment.Stretch };
            lookup_Members = new ComboBox() { HorizontalAlignment = HorizontalAlignment.Stretch };

            lookup_Types.SelectionChanged += lookup_Types_SelectionChanged;
            lookup_Members.SelectionChanged += lookup_Types_SelectionChanged;

            stk.Children.Add(lookup_Types);
            stk.Children.Add(lookup_Members);

            #region Setup dropdown item template
            var lookupItemTemplate = lookup_Members.ItemTemplate = lookup_Types.ItemTemplate = new DataTemplate { DataType = typeof(DCompletionData) };

            var sp = new FrameworkElementFactory(typeof(StackPanel));
            sp.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);
            sp.SetBinding(StackPanel.ToolTipProperty, new Binding("Description"));

            var iTemplate_Img = new FrameworkElementFactory(typeof(Image));
            iTemplate_Img.SetBinding(Image.SourceProperty, new Binding("Image"));
            iTemplate_Img.SetValue(Image.MarginProperty, new Thickness(1, 1, 4, 1));
            sp.AppendChild(iTemplate_Img);

            var iTemplate_Name = new FrameworkElementFactory(typeof(TextBlock));
            iTemplate_Name.SetBinding(TextBlock.TextProperty, new Binding("PureNodeString"));
            sp.AppendChild(iTemplate_Name);

            lookupItemTemplate.VisualTree = sp;
            #endregion

            // Important: Move the members-lookup to column 1
            lookup_Members.SetValue(Grid.ColumnProperty, 1);
            #endregion

            // Register CodeCompletion events
            Editor.TextArea.TextEntering += new System.Windows.Input.TextCompositionEventHandler(TextArea_TextEntering);
            Editor.TextArea.TextEntered += new System.Windows.Input.TextCompositionEventHandler(TextArea_TextEntered);
            Editor.Document.Changed += new EventHandler<ICSharpCode.AvalonEdit.Document.DocumentChangeEventArgs>(Document_Changed);
            Editor.TextArea.Caret.PositionChanged += new EventHandler(TextArea_SelectionChanged);
            Editor.MouseHover += new System.Windows.Input.MouseEventHandler(Editor_MouseHover);
            Editor.MouseHoverStopped += new System.Windows.Input.MouseEventHandler(Editor_MouseHoverStopped);

            Editor.TextArea.IndentationStrategy = indentationStrategy = new DIndentationStrategy(this);
            foldingManager = ICSharpCode.AvalonEdit.Folding.FoldingManager.Install(Editor.TextArea);

            #region Init context menu
            var cm = new ContextMenu();
            Editor.ContextMenu = cm;

            var cmi = new MenuItem() { Header = "Add import directive", ToolTip = "Add an import directive to the document if type cannot be resolved currently" };
            cmi.Click += ContextMenu_AddImportStatement_Click;
            cm.Items.Add(cmi);

            cmi = new MenuItem() { Header = "Go to definition", ToolTip = "Go to the definition that defined the currently hovered item" };
            cmi.Click += new System.Windows.RoutedEventHandler(ContextMenu_GotoDefinition_Click);
            cm.Items.Add(cmi);

            cmi = new MenuItem()
            {
                Header = "Toggle Breakpoint",
                ToolTip = "Toggle breakpoint on the currently selected line",
                Command = D_IDE.Core.Controls.IDEUICommands.ToggleBreakpoint
            };
            cm.Items.Add(cmi);

            cm.Items.Add(new Separator());

            cmi = new MenuItem()
            {
                Header = "Comment selection",
                ToolTip = "Comment out current selection. If nothing is selected, the current line will be commented only",
                Command = D_IDE.Core.Controls.IDEUICommands.CommentBlock
            };
            cm.Items.Add(cmi);

            cmi = new MenuItem()
            {
                Header = "Uncomment selection",
                ToolTip = "Uncomment current block. The nearest comment tags will be removed.",
                Command = D_IDE.Core.Controls.IDEUICommands.UncommentBlock
            };
            cm.Items.Add(cmi);
//.........这里部分代码省略.........
开发者ID:ephe-meral,项目名称:D-IDE,代码行数:101,代码来源:DEditorDocument.cs

示例11: SetSelectedTemplate

 public static void SetSelectedTemplate(ComboBox obj, DataTemplate value)
 {
     obj.SetValue(SelectedTemplateProperty, value);
 }
开发者ID:MGetmanov,项目名称:Selenite,代码行数:4,代码来源:ComboBoxItemTemplateSelector.cs

示例12: cnvPaint_Drop

        void cnvPaint_Drop(object sender, DragEventArgs e)
        {
            if (e.Data.GetData(typeof(Button)) != null)
            {
                if (((Canvas)((Button)e.Data.GetData(typeof(Button))).Parent).Name.ToString() == "cnvControls")
                {

                    Point p = e.GetPosition((IInputElement)cnvPaint);
                    Button btn = new Button();
                    btn.Height = 25;
                    btn.Width = 100;
                    btn.Content = "Button";
                    btn.Background = Brushes.Transparent;
                    btn.PreviewMouseDown += new MouseButtonEventHandler(btnDrag_PreviewMouseDown);
                    btn.SetValue(Canvas.LeftProperty, 10.0);
                    btn.SetValue(Canvas.TopProperty, 10.0);

                    ctlPOD objPOD = new ctlPOD();
                    objPOD.AllowDrop = true;
                    objPOD.Height = 25;
                    objPOD.Width = 100;
                    
                    objPOD.SetValue(Canvas.LeftProperty, p.X);
                    objPOD.SetValue(Canvas.TopProperty, p.Y);
                    MyPropGrid.ControlToBind = objPOD;
                    objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);

                    objPOD.cnvPOD.Children.Add(btn);
                    currentControl = objPOD;
                    cnvPaint.Children.Add(objPOD);
                }
                else if ((((Canvas)((Button)e.Data.GetData(typeof(Button))).Parent).Parent).GetType() == typeof(ctlPOD))
                {
                    //v
                   // if (currentControl.rect.Visibility == Visibility.Visible)
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ((Canvas)((Button)e.Data.GetData(typeof(Button))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                        ((Canvas)((Button)e.Data.GetData(typeof(Button))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);
                    }
                }
            }

            else if (e.Data.GetData(typeof(Label)) != null)
            {
                if (((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Name.ToString() == "cnvControls")
                {
                    Point p = e.GetPosition((IInputElement)cnvPaint);
                    Label lbl = new Label();
                    lbl.Content = "Label";
                    lbl.Background = Brushes.Transparent;
                    lbl.Foreground = Brushes.Black ;
                    lbl.HorizontalContentAlignment = HorizontalAlignment.Center;
                    lbl.Height = 25;
                    lbl.Width = 100;
                    lbl.PreviewMouseDown += new MouseButtonEventHandler(lblDrag_PreviewMouseDown);
                    lbl.SetValue(Canvas.LeftProperty, 10.0);
                    lbl.SetValue(Canvas.TopProperty, 10.0);

                    ctlPOD objPOD = new ctlPOD();
                    objPOD.cnvPOD.Children.Add(lbl);
                    objPOD.AllowDrop = true;
                    objPOD.Height = 25;
                    objPOD.Width = 100;
                    objPOD.SetValue(Canvas.LeftProperty, p.X);
                    objPOD.SetValue(Canvas.TopProperty, p.Y);
                    MyPropGrid.ControlToBind = objPOD;
                    objPOD.KeyDown += new KeyEventHandler(objPOD_KeyDown);
                    objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                    currentControl = objPOD;
                    cnvPaint.Children.Add(objPOD);
                }

                else if ((((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Parent).GetType() == typeof(ctlPOD))
                {
                    Point p = e.GetPosition((IInputElement)cnvPaint);
                    ((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                    ((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);

                }
            }

            else if (e.Data.GetData(typeof(TextBox)) != null)
            {
                if (((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Name.ToString() == "cnvControls")
                {
                    Point p = e.GetPosition((IInputElement)cnvPaint);
                    TextBox txt = new TextBox();
                    txt.Cursor = Cursors.Arrow;
                    txt.Background = Brushes.Transparent;
                    txt.Height = 25;
                    txt.Width = 100;
                    txt.Text = "TextBox";
                    txt.MouseDown += new MouseButtonEventHandler(txt_MouseDown);
                    txt.PreviewMouseDown += new MouseButtonEventHandler(txtDrag_PreviewMouseDown);
                    txt.SetValue(Canvas.LeftProperty, 10.0);
                    txt.SetValue(Canvas.TopProperty, 10.0);


                    ctlPOD objPOD = new ctlPOD();
//.........这里部分代码省略.........
开发者ID:jiangguang5201314,项目名称:VMukti,代码行数:101,代码来源:ctlScriptDesigner.xaml.cs

示例13: SetOpenDropDownAutomatically

 /// <summary>
 /// Sets the open drop down automatically.
 /// </summary>
 /// <param name="cbo">The cbo.</param>
 /// <param name="value">if set to <c>true</c> [value].</param>
 public static void SetOpenDropDownAutomatically(ComboBox cbo, bool value)
 {
     cbo.SetValue(openDropDownAutomaticallyProperty, value);
 }
开发者ID:kennedykinyanjui,项目名称:Projects,代码行数:9,代码来源:ComboBoxDropdownExtensions.cs

示例14: btnOK_Click

        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            try
            {
            cnvOptions.Children.Clear();
            lsttxt.Clear();
            lstActionQue.Clear();
            int number = 0;
            if(txtNoOfOptions.Text.Trim() !="")
            number = Int16.Parse(txtNoOfOptions.Text.Trim());

            for (int i = 0; i < number; i++)
            {
                Label lbl = new Label();
                lbl.Height = 23;
                lbl.Width = 70;
                lbl.Content = "Option " + (i+1).ToString();
                lbl.SetValue(Canvas.LeftProperty, 20.0);
                lbl.SetValue(Canvas.TopProperty, 10 + (25.0 * i));
                cnvOptions.Children.Add(lbl);

                TextBox txt = new TextBox();
                txt.Height = 23;
                txt.Width = 600;
                txt.SetValue(Canvas.LeftProperty, 100.0);
                txt.SetValue(Canvas.TopProperty, 10 + (25.0 * i));
                lsttxt.Add(txt);
                cnvOptions.Children.Add(txt);

                ComboBox cmb = new ComboBox();
                cmb.Height = 23;
                cmb.Width = 300;

                for (int i1 = 0; i1 < lstQuestions.Count; i1++)
                {
                    ComboBoxItem cbi = new ComboBoxItem();
                    cbi.Content = lstQuestions[i1].Header;
                    cbi.Tag = i1.ToString();
                    cmb.Items.Add(cbi);
                }

                cmb.SetValue(Canvas.LeftProperty, 710.0);
                cmb.SetValue(Canvas.TopProperty, 10 + (25.0 * i));
                lstActionQue.Add(cmb);
                //lsttxt.Add(txt);
                cnvOptions.Children.Add(cmb);
                
            }
        }
            catch (Exception exp)
            {
                exp.Data.Add("My Key", "btnOK_Click()--:--clsQuestion.xaml.cs--:--" + exp.Message + " :--:--");
                //ClsException.LogError(ex);
                //ClsException.WriteToErrorLogFile(ex);
                System.Text.StringBuilder sb = new StringBuilder();
                sb.AppendLine(exp.Message);
                sb.AppendLine();
                sb.AppendLine("StackTrace : " + exp.StackTrace);
                sb.AppendLine();
                sb.AppendLine("Location : " + exp.Data["My Key"].ToString());
                sb.AppendLine();
                sb1 = CreateTressInfo();
                sb.Append(sb1.ToString());
                VMuktiAPI.ClsLogging.WriteToTresslog(sb);
            }
        }
开发者ID:jiangguang5201314,项目名称:VMukti,代码行数:66,代码来源:ctlQuestion.xaml.cs

示例15: FncNextQuestion

        void FncNextQuestion()
        {
            try
            {
            cnvMain.Children.Clear();
            currentQuestion = -1;

            for (int i = 0; i < lstQuestions.Count; i++)
            {
                if (lstQuestions[i].Header == StartQuestion)
                {
                    currentQuestion = i;
                    break;
                }
            }

            if (currentQuestion == -1)
                goto exit;
            
            Label lblHeader = new Label();
            lblHeader.Content = lstQuestions[currentQuestion].Header;
            lblHeader.Height = 30;
            lblHeader.Width = 600;
            lblHeader.SetValue(Canvas.LeftProperty, 10.0);
            lblHeader.SetValue(Canvas.TopProperty, 10.0);

            if (lstQuestions[currentQuestion].Type == TypeOfOptions.RadioButton)
            {
                RadioButton[] rdo = new RadioButton[lstQuestions[currentQuestion].NoOfOptions];
                List<string> strOpt = lstQuestions[currentQuestion].Options;
                for (int i = 0; i < lstQuestions[currentQuestion].NoOfOptions; i++)
                {
                    rdo[i] = new RadioButton();
                    string[] str = strOpt[i].Split(new string[] {"*****"}, StringSplitOptions.None);
                    rdo[i].Content = str[0];
                    rdo[i].Tag = str[1];
                    rdo[i].Height = 25;
                    rdo[i].Width = 600;
                    rdo[i].SetValue(Canvas.LeftProperty, 80.0);
                    rdo[i].SetValue(Canvas.TopProperty, 10.0 + ((i + 1) * 30));
                    cnvMain.Children.Add(rdo[i]);
                }
            }

            else if (lstQuestions[currentQuestion].Type == TypeOfOptions.CheckBox)
            {

                CheckBox[] rdo = new CheckBox[lstQuestions[currentQuestion].NoOfOptions];
                List<string> strOpt = lstQuestions[currentQuestion].Options;
                for (int i = 0; i < lstQuestions[currentQuestion].NoOfOptions; i++)
                {

                    rdo[i] = new CheckBox();
                    string[] str = strOpt[i].Split(new string[] { "*****" }, StringSplitOptions.None);
                    rdo[i].Content = str[0];
                    rdo[i].Tag = str[1];
                    rdo[i].Height = 25;
                    rdo[i].Width = 600;
                    rdo[i].SetValue(Canvas.LeftProperty, 80.0);
                    rdo[i].SetValue(Canvas.TopProperty, 10.0 + ((i + 1) * 30));
                    cnvMain.Children.Add(rdo[i]);
                }
            }

            else if (lstQuestions[currentQuestion].Type == TypeOfOptions.ListBox)
            {

                ListBox lst = new ListBox();
                lst.Height = 250;
                lst.Width = 250;
                lst.SetValue(Canvas.LeftProperty, 80.0);
                lst.SetValue(Canvas.TopProperty, 80.0);
                cnvMain.Children.Add(lst);
                ListBoxItem[] lbi = new ListBoxItem[lstQuestions[currentQuestion].NoOfOptions];
                List<string> strOpt = lstQuestions[currentQuestion].Options;
                for (int i = 0; i < lstQuestions[currentQuestion].NoOfOptions; i++)
                {
                    lbi[i] = new ListBoxItem();
                    string[] str = strOpt[i].Split(new string[] { "*****" }, StringSplitOptions.None);
                    lbi[i].Content = str[0];
                    lbi[i].Tag = str[1];
                    lst.Items.Add(lbi[i]);
                }
            }

            else if (lstQuestions[currentQuestion].Type == TypeOfOptions.ComboBox)
            {
                ComboBox cmb = new ComboBox();
                cmb.Height = 30;
                cmb.Width = 250;
                cmb.SetValue(Canvas.LeftProperty, 80.0);
                cmb.SetValue(Canvas.TopProperty, 80.0);
                cnvMain.Children.Add(cmb);
                ComboBoxItem[] cbi = new ComboBoxItem[lstQuestions[currentQuestion].NoOfOptions];
                List<string> strOpt = lstQuestions[currentQuestion].Options;
                for (int i = 0; i < lstQuestions[currentQuestion].NoOfOptions; i++)
                {
                    cbi[i] = new ComboBoxItem();
                    string[] str = strOpt[i].Split(new string[] { "*****" }, StringSplitOptions.None);
                    cbi[i].Content = str[0];
//.........这里部分代码省略.........
开发者ID:jiangguang5201314,项目名称:VMukti,代码行数:101,代码来源:ctlQuestion.xaml.cs


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