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


C# Controls.ListBox类代码示例

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


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

示例1: AutoScrollHandler

 public AutoScrollHandler(System.Windows.Controls.ListBox target)
 {
     Target = target;
     Binding B = new Binding("ItemsSource");
     B.Source = Target;
     BindingOperations.SetBinding(this, ItemsSourceProperty, B);
 }
开发者ID:Kayomani,项目名称:FAP,代码行数:7,代码来源:ListBoxAutoScroll.cs

示例2: GetContent

        protected override FrameworkElement GetContent()
        {
            int totalHeight = 0;
            ListBox removeOptions = new ListBox();

            for(int i = 0 ; i < _tree.Items.Count; i ++)
            
                if (_tree.Items[i] is PatternBase)
                {
                    totalHeight += 25; //default height of an item
                    TextBlock pattern = new TextBlock() 
                    {
                        Text = (_tree.Items[i] as PatternBase).BioPatternName,
                        Name = i.ToString(), //store the id as name so we can remove it later...
                        Width = 150
                    };

                    pattern.MouseLeftButtonUp += new MouseButtonEventHandler(RemoveSelectedPattern);
                    removeOptions.Items.Add(pattern);
                }

            Grid grid = new Grid() 
            { 
                Height = totalHeight,
                Width = 170
            };
            grid.Children.Add(removeOptions);
            return grid;
        }
开发者ID:SamuelToh,项目名称:Masters_Degree_Major_Project,代码行数:29,代码来源:PatternRemoveMenu.cs

示例3: fillList

 private void fillList(ListBox listPlaylist)
 {
     if (!Directory.Exists(PathPlaylist))
         Directory.CreateDirectory(PathPlaylist);
     try
     {
         string[] listFiles = Directory.GetFiles(PathPlaylist, "*.pls");
         foreach (string fileName in listFiles)
         {
             try
             {
                 Playlist onePlaylist = new Playlist(fileName);
                 onePlaylist.ParsePlaylist();
                 listPlaylist.Items.Add(onePlaylist);
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.ToString());
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }
开发者ID:Cathret,项目名称:MyWindowsMediaPlayer,代码行数:26,代码来源:ViewModelPlaylist.cs

示例4: AddSelectionEvent

 static void AddSelectionEvent(ListBox list)
 {
     list.SelectionChanged += delegate
     {
         MessageBox.Show("");
     };
 }
开发者ID:Roommetro,项目名称:Friendly.WPFStandardControls,代码行数:7,代码来源:WPFListBoxTest.cs

示例5: GetInformationToSave

        private static string GetInformationToSave(int cas, MainWindow mw)
        {
            ListBox listBox = new ListBox();

            switch (cas)
            {
                case 1:
                    break;
                case 2:
                    break;
                case 3:
                    break;
                case 4:
                    break;
                case 5:
                    listBox = mw.listBoxError_Test;
                    break;
            }

            string contents = "";
            foreach (string ligne in listBox.Items)
            {
                contents += ligne + "\r\n";
            }

            return contents;
        }
开发者ID:unil,项目名称:fbm-tools,代码行数:27,代码来源:Save.cs

示例6: switch

 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     this.remoteClientList = ((System.Windows.Controls.ListBox)(target));
     return;
     case 2:
     
     #line 18 "..\..\AddAppDialog.xaml"
     ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.OKButton_Clicked);
     
     #line default
     #line hidden
     return;
     case 3:
     
     #line 20 "..\..\AddAppDialog.xaml"
     ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.CancelButton_Clicked);
     
     #line default
     #line hidden
     return;
     }
     this._contentLoaded = true;
 }
开发者ID:Microsoft,项目名称:HoloToolkit,代码行数:25,代码来源:AddAppDialog.g.i.cs

示例7: OnApplyTemplate

        public override void OnApplyTemplate()
        {
            if (ResultsListBox != null)
                ResultsListBox.SelectionChanged -= ResultListBox_SelectionChanged;
            if (MapDetailsControl != null)
            {
                MapDetailsControl.MapDetailsChanged -= RaiseMapDetailsChanged;
                MapDetailsControl.MapSelectedForOpening -= RaiseMapSelectedForOpening;
            }
            base.OnApplyTemplate();
            MapDetailsControl = GetTemplateChild("MapDetailsControl") as MapDetailsControl;
            ResultsListBox = GetTemplateChild("ResultsListBox") as ListBox;

            if (ResultsListBox != null)
            {
                ResultsListBox.SelectionChanged += ResultListBox_SelectionChanged;
                ResultsListBox.Tag = this;
            }

            if (MapDetailsControl != null)
            {
                MapDetailsControl.MapDetailsChanged += RaiseMapDetailsChanged;
                MapDetailsControl.MapSelectedForOpening += RaiseMapSelectedForOpening;
            }
        }
开发者ID:Esri,项目名称:arcgis-viewer-silverlight,代码行数:25,代码来源:FeaturedMapsControl.xaml.cs

示例8: ListColorNames

        public ListColorNames()
        {
            Title = "List Color Names";

            ListBox lstbox = new ListBox();
            lstbox.Width = 150;   // ��
            lstbox.Height = 150;  //����
            lstbox.SelectionChanged += ListBoxOnSelectionChanged;   // �̺�Ʈ ���
            Content = lstbox;          //win�� ���(ȭ�鿡 ���)

            //1��
            /*
            //��������� ListBox�� ü���
            PropertyInfo[] props = typeof(Colors).GetProperties();
            //GetProperties �� Colors�� �ִ� ������Ƽ 141���� �迭�� �����´�.
            //������ PropertyInfo Ÿ���� �迭�� �ϳ��� ������ Name���� �̸��� ����Ʈ �ڽ��� �߰��Ѵ�.
            foreach (PropertyInfo prop in props)
                lstbox.Items.Add(prop.Name);
            */

            //2��

            PropertyInfo[] props = typeof(Colors).GetProperties();
            //����Ʈ �ڽ��� Color ������ ü���...
            foreach (PropertyInfo prop in props)
                lstbox.Items.Add(prop.GetValue(null, null));
        }
开发者ID:gawallsibya,项目名称:BIT_MFC-CShap-DotNet,代码行数:27,代码来源:ListColorNames.cs

示例9: CreateAndInitListBox

        private ListBox CreateAndInitListBox()
        {
            ListBox lst = new ListBox();

            lst.Margin = new Thickness(10, 10, 10, 10);
            return lst;
        }
开发者ID:expanz,项目名称:expanz-Microsoft-XAML-SDKs,代码行数:7,代码来源:ClientMessageControl.xaml.cs

示例10: worker_RunWorkerCompleted

 void worker_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
 {
     var winFabSortedList = winFabInterest;
     ListBox lstBx = new ListBox();
     lstBx.Height = this.MainPanel.Height;
     lstBx.Width = this.MainPanel.Width;
     this.MainPanel.Children.Add(lstBx);
     if (winFabSortedList.Count == 0)
     {
         MessageBox.Show("No Records Found.Try changing the folder option.");
     }
     else
     {
         foreach (var itm in winFabSortedList)
         {
             EmailDataModel emailObj = new EmailDataModel();
             emailObj.SenderName = itm.SenderName;
             emailObj.SenderGroup = itm.SenderGroup;
             emailObj.SenderParticipation = itm.SenderParticipation;
             emailObj.SenderContact = itm.SenderContact;
             InterestControl intControl = new InterestControl();
             intControl.SetUI(emailObj);
             lstBx.Items.Add(intControl);
         }
     }
     this.EllipseAnimate.Visibility = Visibility.Collapsed;
     this.EllipseAnimate.Visibility = Visibility.Collapsed;
     this.UpdateLayout();
 }
开发者ID:Nabarun,项目名称:OutlookAnalyzer,代码行数:29,代码来源:MainWindow.xaml.cs

示例11: IsFirstItemVisible

        public static bool IsFirstItemVisible(ListBox listbox)
        {
            if (listbox.Items.Count == 0)
                return false;

            var listboxRectangle = new Rect(new Point(0, 0), listbox.RenderSize);

            double visiblePercent = 0;

            ListBoxItem item = listbox.ItemContainerGenerator.ContainerFromIndex(0) as ListBoxItem;
            if (item != null)
            {
                var itemTransform = item.TransformToVisual(listbox);
                var itemRectangle = itemTransform.TransformBounds(new Rect(new Point(0, 0), item.RenderSize));
                itemRectangle.Intersect(listboxRectangle);

                if (!itemRectangle.IsEmpty)
                {
                    visiblePercent = itemRectangle.Height / item.RenderSize.Height * 100;
                }
            }

            if (visiblePercent > 0)
                return true;
            else
                return false;
        }
开发者ID:optiklab,项目名称:VKMessanger,代码行数:27,代码来源:WindowsPhoneHelpers.cs

示例12: AddItemToList

 public void AddItemToList(RecognitionResult speech, ListBox list, Color color)
 {
     ListBoxItem item = CreateDefaultListBoxItem();
     item.Content = "S:" + speech.Text + " C:" + speech.Confidence;
     item.Foreground = new SolidColorBrush(color);
     AddToList(list, item);
 }
开发者ID:LucioC,项目名称:class_share,代码行数:7,代码来源:ListBoxHelper.cs

示例13: ListColorsEvenElegantlier

        public ListColorsEvenElegantlier()
        {
            Title = "List Colors Even Elegantlier";

            DataTemplate template = new DataTemplate(typeof(NamedBrush));
            FrameworkElementFactory factoryStack = new FrameworkElementFactory(typeof(StackPanel));
            factoryStack.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);
            template.VisualTree = factoryStack;

            FrameworkElementFactory factoryRectangle = new FrameworkElementFactory(typeof(Rectangle));
            factoryRectangle.SetValue(Rectangle.WidthProperty, 16.0);
            factoryRectangle.SetValue(Rectangle.HeightProperty, 16.0);
            factoryRectangle.SetValue(Rectangle.MarginProperty, new Thickness(2));
            factoryRectangle.SetValue(Rectangle.StrokeProperty, SystemColors.WindowTextBrush);
            factoryRectangle.SetBinding(Rectangle.FillProperty, new Binding("Brush"));
            factoryStack.AppendChild(factoryRectangle);

            FrameworkElementFactory factoryTextBlock = new FrameworkElementFactory(typeof(TextBlock));
            factoryTextBlock.SetValue(TextBlock.VerticalAlignmentProperty, VerticalAlignment.Center);
            factoryTextBlock.SetValue(TextBlock.TextProperty, new Binding("Name"));
            factoryStack.AppendChild(factoryTextBlock);

            ListBox lstbox = new ListBox();
            lstbox.Width = 150;
            lstbox.Height = 150;
            Content = lstbox;

            lstbox.ItemTemplate = template;
            lstbox.ItemsSource = NamedBrush.All;

            lstbox.SelectedValuePath = "Brush";
            lstbox.SetBinding(ListBox.SelectedValueProperty, "Background");
            lstbox.DataContext = this;
        }
开发者ID:JianchengZh,项目名称:kasicass,代码行数:34,代码来源:ListColorsEvenElegantlier.cs

示例14: switch

        void IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
                case 1:
                    this.syncMovies = (CheckBox) target;
                    return;

                case 2:
                    this.syncMoviesAll = (CheckBox) target;
                    return;

                case 3:
                    this.moviesListBox = (ListBox) target;
                    this.moviesListBox.PreviewKeyDown += new KeyEventHandler(this.listBox_PreviewKeyDown);
                    return;

                case 4:
                    this.drmMessage = (TextBlock) target;
                    return;

                case 5:
                    this.cancelButton = (Button) target;
                    return;

                case 6:
                    this.syncButton = (Button) target;
                    return;
            }
            this._contentLoaded = true;
        }
开发者ID:netonjm,项目名称:WindowsPhone,代码行数:31,代码来源:PCMoviesPanel.cs

示例15: show

        public void show(MainWindow con, ListBox lb, string kto, string text, int tem)
        {
            if (!lb.CheckAccess())
            {
                con.Dispatcher.Invoke(DispatcherPriority.Send,
                (Action)delegate
                {
                    UserWiad itm = new UserWiad();
                    itm.Nick = kto;
                    itm.Wiad = text;
                    itm.Typ = tem;
                    lb.Items.Add(itm);
                    lb.ScrollIntoView(itm);
                });
            }
            else
            {
                UserWiad itm = new UserWiad();
                itm.Nick = kto;
                itm.Wiad = text;
                itm.Typ = tem;
                lb.Items.Add(itm);

                lb.ScrollIntoView(itm);
            }
        }
开发者ID:MichalPL,项目名称:C-Sharp-Moje-Projekty,代码行数:26,代码来源:NewMessage.cs


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