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


C# Controls.ListBoxItem类代码示例

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


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

示例1: MessageListBox

 protected MessageListBox(List<TheoryTypes> items, Mods mod)
 {
     InitializeComponent();
     this.mod = mod;
     if (mod == Mods.Edit)
     {
         throw new NotImplementedException("Так вот.");
     }
     else if (mod == Mods.Choose)
     {
         typeOfElement = typeof(TheoryTypes);
         ListBox listbox = new ListBox();
         ListBoxItem item;
         foreach (TheoryTypes type in items)
         {
             item = new ListBoxItem();
             item.Name = type.ToString();
             item.Content = type;
             listbox.Items.Add(item);
         }
         listbox.SelectionChanged += new SelectionChangedEventHandler(Listbox_SelectionChanged);
         Box.Content = listbox;
     }
     LanguageResource_Updated(null);
 }
开发者ID:protsenkovi,项目名称:Theory-Editor,代码行数:25,代码来源:MessageListBox.xaml.cs

示例2: Render

        public UIElement Render()
        {
            var list = new System.Windows.Controls.ListBox();
            foreach (var noteItem in this.NoteItems)
            {
                var renderedNoteItem = noteItem.Render(this.NoteItems.IndexOf(noteItem));

                var listNodeItemItem = new ListBoxItem();
                listNodeItemItem.Content = renderedNoteItem;
                var deleteButtons = (renderedNoteItem as System.Windows.Controls.Panel).Children.OfType<System.Windows.Controls.Button>();
                foreach (var delButton in deleteButtons)
                {

                    delButton.PreviewMouseDown += (snd, args) =>
                    {
                        //have to find the index of the item, that should be deleted !!!

                        var toBeDeleted = this.NoteItems[(int)delButton.DataContext];
                        this.NoteItems.RemoveAt((int)delButton.DataContext); //[index]
                        list.Items.RemoveAt((int)delButton.DataContext);
                        RemoveFromFile(toBeDeleted);
                        CopyData();

                    };
                }

                list.Items.Add(listNodeItemItem);
            }
            return list;
        }
开发者ID:pepakam,项目名称:TelerikAcademy,代码行数:30,代码来源:NotesList.cs

示例3: selectFilesButton_Click

        private void selectFilesButton_Click(object sender, RoutedEventArgs e)
        {
            var dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.Multiselect = true;

            bool? result = dlg.ShowDialog();

            if (result == true)
            {
                dlg.FileNames.ToList().ForEach(filename =>
                {
                    var newItem = new ListBoxItem()
                    {
                        Content = System.IO.Path.GetFileName(filename),
                        Tag = filename
                    };

                    ImageFileCollection.Add(newItem);
                });

                CheckDuplicates();

                ValidateInputPage();
            }
        }
开发者ID:volkanx,项目名称:image2pdf,代码行数:25,代码来源:MainWindow.xaml.cs

示例4: UserControl_Loaded

        private void UserControl_Loaded (object sender, RoutedEventArgs e)
        {
            listBox1.Items.Clear();

            for (int i = 0; i < imageFiles.Count; i++)
            {
                ListBoxItem lbi = new ListBoxItem();
                Image im = new Image();

                im.Source = ((ImageInfo)imageFiles[i]).imageSource;
                double ratio = im.Source.Height / im.Source.Width;

                lbi.Height = ratio * listBox1.Width;
                im.Width = 0.9 * listBox1.Width;
                im.Height = lbi.Height * 0.9;

                lbi.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;

                im.Stretch = System.Windows.Media.Stretch.Fill;
                lbi.Content = im;
                listBox1.Items.Add(lbi);
            }


            if (listBox1.Items.Count > 0)
                listBox1.SelectedIndex = 0;
        }
开发者ID:BdGL3,项目名称:CXPortal,代码行数:27,代码来源:UserControl1.xaml.cs

示例5: ChangeMCVersion

        public ChangeMCVersion()
        {
            InitializeComponent();
            try
            {
                foreach (TinyMinecraftVersion ver in VersionManager.versions)
                {
                    ListBoxItem item = new ListBoxItem();
                    item.Content = ver.Key;
                    item.Tag = ver;

                    if (ver.Type == ReleaseType.release)
                        lb_release.Items.Add(item);
                    else if (ver.Type == ReleaseType.snapshot)
                        lb_snapshot.Items.Add(item);
                    else
                        lb_instance.Items.Add(item);
                }
            }
            catch
            {
                MessageBox mb = new MessageBox("Warning!","The versions haven't initialized yet");
                mb.Show();
                this.Close();
            }
        }
开发者ID:Northcode,项目名称:MCM-reboot,代码行数:26,代码来源:ChangeMCVersion.xaml.cs

示例6: FillComboBox

		public void FillComboBox (ComboBox UsedComboBox, Object Data, String TableName, String ItemName, String ContentToSelect)
			{
			WCFStandardsNS.TableDescription TableDesc = ClientSchema.TableDictionary [TableName];
			WCFStandardsNS.ItemDescription ItemDesc = TableDesc.ItemDictionary [ItemName];
			WCFStandardsNS.AssociationDescription Assoc = ItemDesc.GetChildAssociation ();
			if (Assoc == null)
				return;

			DataSet FillDataSet = WCFAccess.GetCommonDataSet (Assoc.ParentTable.SqlFill);
			foreach (DataRow FillRow in FillDataSet.Tables [0].Rows)
				{
				ListBoxItem Item = new ListBoxItem ();
				Item.Tag = FillRow;
				List<String> DisplayList = new List<string> ();
				foreach (String FillItem in Assoc.ParentTable.LinqFillItems)
					{
					if (FillItem == "ID")
						{
						if (FillRow [FillItem].ToString () == ContentToSelect)
							Item.IsSelected = true;
						continue;
						}
					DisplayList.Add (FillRow [FillItem].ToString ());
					}
				Item.Content = String.Join (", ", DisplayList.ToArray ());
				UsedComboBox.Items.Add (Item);
				}
			}
开发者ID:heinzsack,项目名称:DEV,代码行数:28,代码来源:ControlHandler.cs

示例7: displayMails

        internal void displayMails()
        {
            int id = 0;

            LoadingDialog md = new LoadingDialog();
            md.Buttons = null;
            md.Show();
            loadInboxAndSent();
            md.Close();

            foreach (Mail m in this.mm.Inbox)
            {
                ListBoxItem newMail = new ListBoxItem();
                StackPanel mailContainer = new StackPanel();
                Label subject = new Label();

                mailContainer.Width = 450;

                subject.Tag = id;
                subject.Content = m.Title;

                mailContainer.Children.Add(subject);

                newMail.Content = mailContainer;

                this.EmailList.Items.Add(newMail);
                id++;
            }
        }
开发者ID:granigd,项目名称:Mail-Project,代码行数:29,代码来源:SelectInbox.xaml.cs

示例8: MainWindow

        public MainWindow()
        {
            InitializeComponent();

            // disable console
            tb_console.IsEnabled = false;

            for (int i = 0; i < 3; i++) {
                ListBoxItem lbi = new ListBoxItem();
                lbi.Width = 100;
                lbi.Height = 100;
                lbi.Content = "test";
                lbi.Background = Brushes.Red;
                ListBoxProductBacklog.Items.Add(lbi);
            }

            #region Socket Setup

            threadMonitor.ThreadEvent += Thread_MessageReciever;
            TcpClient tcpClient = new TcpClient("25.106.204.166", 1234);
            //tb_console.Text += "Connected to server.";
            sWriter = new StreamWriter(tcpClient.GetStream());
            Thread thread = new Thread(Read);
            thread.Start(tcpClient);
            #endregion
        }
开发者ID:peterbork,项目名称:Scrumboard,代码行数:26,代码来源:MainWindow.xaml.cs

示例9: Button_Click

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (HasRolled == false)
            {
                HasRolled = true;
                RollButton.Content = "Re-roll Stats";
            }
            if (Rolls.HasItems == true) Rolls.Items.Clear();
            //int[] rolls = new int[4];
            //Random r = new Random();
            //rolls[0] = r.Next(1, 7);
            //rolls[1] = r.Next(1, 7);
            //rolls[2] = r.Next(1, 7);
            //rolls[3] = r.Next(1, 7);
            //int min = rolls.Min();
            //int total = rolls.Sum();

            //foreach (var roll in rolls)
            //{
            //    Rolls.Items.Add(roll);
            //}
            //Rolls.Items.Add(min);
            //Rolls.Items.Add(total);
            Random rr = new Random();
            for (int ii = 0; ii < 6; ii++)
            {
                ListBoxItem lbi = new ListBoxItem();
                lbi.Content = RollForIt(rr);
                Rolls.Items.Add(lbi);
            }
        }
开发者ID:mrdeadsake,项目名称:dndReboot,代码行数:31,代码来源:Roll.xaml.cs

示例10: FulcrumWindow

 public FulcrumWindow()
 {
     InitializeComponent();
     try
     {
         //grab the forms associated with the api key and put in the box
         fulcrumForms = FulcrumCore.GetForms();
         if (fulcrumForms != null)
         {
             foreach (fulcrumform form in fulcrumForms.forms)
             {
                 ListBoxItem item = new ListBoxItem();
                 item.Tag = form.id;
                 item.Content = (form.name);
                 this.listboxForms.Items.Add(item);
             }
         }
         else
         {
             MessageBox.Show("Unable to retrieve Fulcrum data at this time.", "Fulcrum Tools", MessageBoxButton.OK, MessageBoxImage.Exclamation);
             this.Hide();
         }
     }
     catch (Exception e)
     {
         string ouch = e.Message;
         MessageBox.Show("Unable to retrieve Fulcrum data at this time.", "Fulcrum Tools", MessageBoxButton.OK, MessageBoxImage.Exclamation);
         this.Hide();
     }
 }
开发者ID:brightrain,项目名称:arcgis-fulcrum-add-in,代码行数:30,代码来源:fulcrumWindow.xaml.cs

示例11: button1_Click

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            var stackPannel = new StackPanel();
            var value = new ListBoxItem();
            value.Content = "False";
            value.Foreground = Brushes.White;
            value.Background = Brushes.Red;
            value.MouseUp += Value_MouseUp;

            var img = new ImgButton()
            {
                Content = "+",
                Width = 30,
                Foreground = Brushes.White,
                Background = Brushes.YellowGreen
            };
            img.Click += Img_Click;

            stackPannel.Children.Add(new Label() { Content = "Новый элемент" });
            stackPannel.Children.Add(value);
            stackPannel.Children.Add(img);
            stackPannel.Orientation = Orientation.Horizontal;

            var item = new ListBoxItem();
            item.Content = stackPannel;
            item.Selected += Item_Selected;

            choices.Items.Add(item);
            choices.SelectedItem = item;
        }
开发者ID:Vovanella95,项目名称:TestEditor2015,代码行数:30,代码来源:Choise.xaml.cs

示例12: IsOnCurrentPage

        internal bool IsOnCurrentPage(ListBoxItem item)
        {
            var itemsHostRect = Rect.Empty;
            var listBoxItemRect = Rect.Empty;

            if (_visual == null)
            {
                ItemsControlHelper ich = new ItemsControlHelper(ListBox);
                ScrollContentPresenter scp = ich.ScrollHost == null ? null : ich.ScrollHost.GetVisualDescendants().OfType<ScrollContentPresenter>().FirstOrDefault();
                _visual = (ich.ScrollHost == null) ? null : ((scp == null) ? ((FrameworkElement)ich.ScrollHost) : ((FrameworkElement)scp));
            }

            if (_visual == null)
                return true;

            itemsHostRect = new Rect(0.0, 0.0, _visual.ActualWidth, _visual.ActualHeight);
            //ListBoxItem item = ListBox.ItemContainerGenerator.ContainerFromIndex(index) as ListBoxItem;
            if (item == null)
            {
                listBoxItemRect = Rect.Empty;
                return false;
            }

            GeneralTransform transform = item.TransformToVisual(_visual);
            listBoxItemRect = new Rect(transform.Transform(new Point()), transform.Transform(new Point(item.ActualWidth, item.ActualHeight)));
            if (!this.IsVerticalOrientation())
            {
                return ((itemsHostRect.Left <= listBoxItemRect.Left) && (listBoxItemRect.Right <= itemsHostRect.Right));
            }

            return ((listBoxItemRect.Bottom + 100 >= itemsHostRect.Top) && (listBoxItemRect.Top - 100 <= itemsHostRect.Bottom));
            //return ((itemsHostRect.Top <= listBoxItemRect.Bottom) && (listBoxItemRect.Top <= itemsHostRect.Bottom));
        }
开发者ID:284247028,项目名称:MvvmCross,代码行数:33,代码来源:TurnstileFeatherAnimator.cs

示例13: echo

 private void echo(string s, Brush c)
 {
     ListBoxItem li = new ListBoxItem();
     li.Foreground = c;
     li.Content = s;
     listBox1.Items.Add(li);
 }
开发者ID:kellyelton,项目名称:octgn-customizer,代码行数:7,代码来源:DeepGameScan.xaml.cs

示例14: newLBitem

 private ListBoxItem newLBitem(String name, String tag)
 {
     ListBoxItem c = new ListBoxItem();
     c.Content = name;
     c.Tag = tag;            
     return c;
 }
开发者ID:kaizadj,项目名称:ebu-radio-production,代码行数:7,代码来源:UIPeriodItem.xaml.cs

示例15: Load_Networks

        private void Load_Networks()
        {
            string SQL;
            string NetID, Netname;

            SQL = "select NetworkID, NetName from Networks";
            OleDbCommand aCommand = new OleDbCommand(SQL, localengine.RepositoryConnection);
            try
            {
                //create the datareader object to connect to table
                OleDbDataReader aReader = aCommand.ExecuteReader();

                //Iterate throuth the database
                while (aReader.Read())
                {
                    NetID = aReader.GetString(0);
                    Netname = aReader.GetString(1);

                    ListBoxItem li = new ListBoxItem();
                    li.Content = Netname;
                    li.Tag = NetID;
                    ContainNetworks.Items.Add(li);
                }
                aReader.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
开发者ID:2014-sed-team3,项目名称:term-project,代码行数:30,代码来源:Networkmanager.xaml.cs


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