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


C# ListBox.SetValue方法代码示例

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


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

示例1: SetAutoScroll

 public static void SetAutoScroll(ListBox instance, bool value)
 {
     var oldHandler = (AutoScrollHandler)instance.GetValue(AutoScrollHandlerProperty);
     if (oldHandler != null)
     {
         oldHandler.Dispose();
         instance.SetValue(AutoScrollHandlerProperty, null);
     }
     instance.SetValue(AutoScrollProperty, value);
     if (value)
         instance.SetValue(AutoScrollHandlerProperty, new AutoScrollHandler(instance));
 }
开发者ID:leo90skk,项目名称:qdms,代码行数:12,代码来源:ListBoxExt.cs

示例2: SetSelectedItemsBinding

 public static void SetSelectedItemsBinding(ListBox element, bool value)
 {
     element.SetValue(SelectedItemsProperty, value);
     if (value)
     {
         element.SelectionChanged += (sender, args) =>
         {
             var x = element.SelectedItems;
         };
     }
 }
开发者ID:RandomlyKnighted,项目名称:QMAC,代码行数:11,代码来源:ListBoxFix.cs

示例3: GetOrCreateBehavior

        private static ListSelectCommandBehavior GetOrCreateBehavior(ListBox selector)
        {
            var behavior = selector.GetValue(SelectCommandBehaviorProperty) as ListSelectCommandBehavior;
            if (behavior == null)
            {
                behavior = new ListSelectCommandBehavior(selector);
                selector.SetValue(SelectCommandBehaviorProperty, behavior);
            }

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

示例4: GetOrCreateBehavior

        private static SelectedItemsBehavior GetOrCreateBehavior(ListBox target, IList list)
        {
            var behavior = target.GetValue(SelectedItemsBehaviorProperty) as SelectedItemsBehavior;
            if (behavior == null)
            {
                behavior = new SelectedItemsBehavior(target, list);
                target.SetValue(SelectedItemsBehaviorProperty, behavior);
            }

            return behavior;
        }
开发者ID:Jitlee,项目名称:WPFMonitor,代码行数:11,代码来源:MutiListBox.cs

示例5: SetHasBindableSelectedItems

 public static void SetHasBindableSelectedItems(ListBox source, bool value)
 {
     SelectionChangedHandler Handler = (SelectionChangedHandler)source.GetValue(SelectionChangedHandlerProperty);
     if (value && Handler == null)
     {
         Handler = new SelectionChangedHandler(source);
         source.SetValue(SelectionChangedHandlerProperty, Handler);
     }
     else if (!value && Handler != null)
     { source.ClearValue(SelectionChangedHandlerProperty); }
 }
开发者ID:gitter-badger,项目名称:myManga,代码行数:11,代码来源:ListBoxExtentions.cs

示例6: GetOrCreateBehavior

        private static ListBoxSelectionChangedCommandBehavior GetOrCreateBehavior(ListBox ListBox)
        {
            ListBoxSelectionChangedCommandBehavior behavior =
            ListBox.GetValue(SelectCommandBehaviorProperty) as ListBoxSelectionChangedCommandBehavior;

              if (behavior == null)
              {
            behavior = new ListBoxSelectionChangedCommandBehavior(ListBox);
            ListBox.SetValue(SelectCommandBehaviorProperty, behavior);
              }
              return behavior;
        }
开发者ID:mohankumarcm,项目名称:sse554-project3,代码行数:12,代码来源:ListBoxSelect.cs

示例7: ListBox

        public void ListBox(ListBox control)
        {
            // Setup initial conditions.
            control.Width = 300;
            control.Height = 200;

            // Populate listbox with random data.
            var list = new List<string>();
            for (int i = 1; i <= 200; i++)
            {
                list.Add(string.Format("{0} - {1}", i, RandomData.LoremIpsum(1,3)));
            }
            control.ItemsSource = list;

            // Apply the behavior.
            control.SetValue(Behaviors.ListBoxMouseWheelScrollerProperty, new ListBoxMouseWheelScroller());
        }
开发者ID:philcockfield,项目名称:Open.TestHarness.SL,代码行数:17,代码来源:MouseWheelScroller.ViewTest.cs

示例8: SetItems

 public static void SetItems(ListBox listBox, IList list)
 {
     listBox.SetValue(ItemsProperty, list);
 }
开发者ID:pmacn,项目名称:VoiceRecorder.WP8,代码行数:4,代码来源:SelectedItemsBehavior.cs

示例9: SetCommandParameter

 public static void SetCommandParameter(ListBox ListBox, object parameter)
 {
     ListBox.SetValue(CommandParameterProperty, parameter);
 }
开发者ID:mohankumarcm,项目名称:sse554-project3,代码行数:4,代码来源:ListBoxSelect.cs

示例10: SetListBoxMouseWheelScroller

 public static void SetListBoxMouseWheelScroller(ListBox element, ListBoxMouseWheelScroller value) { element.SetValue(ListBoxMouseWheelScrollerProperty, value); }
开发者ID:philcockfield,项目名称:Open.TestHarness.SL,代码行数:1,代码来源:Behaviors.cs

示例11: 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

示例12: UpdateActivatedIndex

        private static void UpdateActivatedIndex(ListBox listBox, object value)
        {
            // find index of activated item
            int index;
            if (value == null)
            {
                index = -1;
            }
            else
            {
                index = 0;
                foreach (var item in listBox.Items)
                {
                    if (item == value)
                        break;
                    index++;
                }
            }

            if (index >= listBox.Items.Count)
                index = -1;

            listBox.SetValue(ActiveIndexPropertyKey, index);
        }
开发者ID:Boddlnagg,项目名称:WordsLive,代码行数:24,代码来源:Activator.cs

示例13: SetIsBroughtIntoViewWhenInserted

 public static void SetIsBroughtIntoViewWhenInserted(ListBox listBox, bool value)
 {
     listBox.SetValue(IsBroughtIntoViewWhenInsertedProperty, value);
 }
开发者ID:blacktau,项目名称:temporaltwist,代码行数:4,代码来源:BringIntoViewWhenInsertedListBoxItemBehaviour.cs

示例14: createSocket

        //Currently creates numeric text boxes
        public void createSocket(string type, bool multiple)
        {
            SocketDragDropTarget target = new SocketDragDropTarget();
            target.socketType = type;

            Style style = new Style(typeof(ListBoxItem));
            style.Setters.Add(new Setter(ListBoxItem.PaddingProperty, new Thickness(-1)));

            if (type.Contains("CONDITION"))
                target.isCondition = true;
            if (type.Contains("CONSTANT"))
                target.isConstant = true;

            ListBox listBox = new ListBox();
            listBox.Height = LayoutRoot.Height - 2;
            listBox.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Hidden);
            listBox.ItemContainerStyle = style;
            /*if (multiple)
            {
                listBox.Width = LayoutRoot.Width * .6;
                //listBox.MinWidth = LayoutRoot.Width * .75;

                //listBox.Width = LayoutRoot.Width * .33;//175;
            }
            else*/
                listBox.Width = LayoutRoot.Width * .75;//350;

            listBox.BorderThickness = new Thickness(2);
            listBox.Background = new SolidColorBrush(Colors.LightGray);
            target.Content = listBox;
            innerPane.Children.Add(target);
        }
开发者ID:dhumphri,项目名称:CSE485-Columba,代码行数:33,代码来源:Block.xaml.cs

示例15: createParameterList

        private void createParameterList()
        {
            flag_hasSocks = false;
            StackPanel webby2 = new StackPanel();
            webby2.Orientation = Orientation.Vertical;
            innerPane.Children.Add(webby2);
            for (int i = 0; i < parameterList.Count; i++)
            {
                flag_hasSocks = true;
                SocketDragDropTarget target = new SocketDragDropTarget();
                target.socketType = parameterList[i];

                Style style = new Style(typeof(ListBoxItem));
                style.Setters.Add(new Setter(ListBoxItem.PaddingProperty, new Thickness(-1)));

                if (type.Contains("CONDITION"))
                    target.isCondition = true;
                if (type.Contains("CONSTANT"))
                    target.isConstant = true;

                ListBox listBox = new ListBox();
                ObservableCollection<Block> collection = new ObservableCollection<Block>();
                listBox.Height = 40;
                listBox.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Hidden);
                listBox.ItemContainerStyle = style;
                listBox.Width = LayoutRoot.Width * .6;
                listBox.BorderThickness = new Thickness(2);
                listBox.Background = new SolidColorBrush(Colors.LightGray);
                listBox.ItemsSource = collection;
                target.Content = listBox;
                if(i > 0)
                    LayoutRoot.Height = LayoutRoot.Height + listBox.Height;
                webby2.Children.Add(target);
            }
        }
开发者ID:dhumphri,项目名称:CSE485-Columba,代码行数:35,代码来源:Block.xaml.cs


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