當前位置: 首頁>>代碼示例>>C#>>正文


C# ListBoxItem.BringIntoView方法代碼示例

本文整理匯總了C#中System.Windows.Controls.ListBoxItem.BringIntoView方法的典型用法代碼示例。如果您正苦於以下問題:C# ListBoxItem.BringIntoView方法的具體用法?C# ListBoxItem.BringIntoView怎麽用?C# ListBoxItem.BringIntoView使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Controls.ListBoxItem的用法示例。


在下文中一共展示了ListBoxItem.BringIntoView方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: UpdateHighlightedItem

        private void UpdateHighlightedItem(ListBoxItem newItem)
        {
            if (HighlightedItem == newItem)
                return;

            // Unselect old value.
            if (HighlightedItem != null)
                HighlightedItem.IsSelected = false;

            HighlightedItem = newItem;

            // Select new value.
            if (HighlightedItem != null)
            {
                HighlightedItem.IsSelected = true;
                HighlightedItem.BringIntoView();
            }
        }
開發者ID:ankushraizada,項目名稱:Dynamo,代碼行數:18,代碼來源:IncanvasSearchControl.xaml.cs

示例2: DragOverOrDrop

        /// <summary>
        /// First determine whether the drag data is supported.
        /// Second determine what type the container is.
        /// Third determine what operation to do (only copy is supported).
        /// And finally handle the actual drop when <code>bDrop</code> is true.
        /// </summary>
        /// <param name="bDrop">True to perform an actual drop, otherwise just return e.Effects</param>
        /// <param name="sender">DragDrop event <code>sender</code></param>
        /// <param name="e">DragDrop event arguments</param>
        private void DragOverOrDrop(bool bDrop, object sender, DragEventArgs e)
        {
            string[] files = this.GetData(e) as string[];
            if(files != null) {
                e.Effects = DragDropEffects.None;
                ItemsControl dstItemsControl = sender as ItemsControl;  // 'sender' is used when dropped in an empty area
                if(dstItemsControl != null) {
                    foreach(string file in files) {
                        if(sender is TabControl) {
                            if(bDrop) {
                                TabItem item = new TabItem();
                                item.Header = System.IO.Path.GetFileName(file);
                                item.ToolTip = file;
                                dstItemsControl.Items.Insert(0, item);
                                item.IsSelected = true;
                            }
                            e.Effects = DragDropEffects.Copy;
                        }
                        else if(sender is ListBox) {
                            if(bDrop) {
                                ListBoxItem dstItem = Utilities.FindParentControlIncludingMe<ListBoxItem>(e.Source as DependencyObject);
                                ListBoxItem item = new ListBoxItem();
                                item.Content = System.IO.Path.GetFileName(file);
                                item.ToolTip = file;
                                if(dstItem == null)
                                    dstItemsControl.Items.Add(item);    // ... if dropped on an empty area
                                else
                                    dstItemsControl.Items.Insert(dstItemsControl.Items.IndexOf(dstItem), item);

                                item.IsSelected = true;
                                item.BringIntoView();
                            }
                            e.Effects = DragDropEffects.Copy;
                        }
                        else if(sender is TreeView) {
                            if(bDrop) {
                                if(e.Source is ItemsControl)
                                    dstItemsControl = e.Source as ItemsControl; // Dropped on a TreeViewItem
                                TreeViewItem item = new TreeViewItem();
                                item.Header = System.IO.Path.GetFileName(file);
                                item.ToolTip = file;
                                dstItemsControl.Items.Add(item);
                                item.IsSelected = true;
                                item.BringIntoView();
                            }
                            e.Effects = DragDropEffects.Copy;
                        }
                        else {
                            throw new NotSupportedException("The item type is not implemented");
                        }
                        // No need to loop through multiple
                        // files if we're not dropping them
                        if(!bDrop)
                            break;
                    }
                }
                e.Handled = true;
            }
        }
開發者ID:hansuky,項目名稱:Yuhan,代碼行數:68,代碼來源:FileDropConsumer.cs

示例3: CreateNewPerson

		public String CreateNewPerson (ListBox PersonenListBox)
			{
			String PersonenIDToCreate = System.Guid.NewGuid ().ToString ();
			String InsertCommand = "INSERT INTO [Personen] ([ID], [Name], [Bereich]) VALUES " +
								"('" + PersonenIDToCreate + "', 'N Bitte Werte eintragen', '" + m_Bereich + "')";
			DataBase.RunSQLBatch (InsertCommand);
			String SelectStatement = "Select * from PersonenFull where ID = '" + PersonenIDToCreate
				+ "' and Bereich = '" + m_Bereich + "'";
			DataSet NewPersonenDataSet = DataBase.GetCommonDataSet (SelectStatement);
			if (NewPersonenDataSet.Tables ["PersonenFull"].Rows.Count < 1)
				return "";
			DataRow NewFullPerson = NewPersonenDataSet.Tables ["PersonenFull"].Rows [0];
			ListBoxItem NewEntry = new ListBoxItem ();
			NewEntry.Tag = PersonenIDToCreate;
			NewEntry.Content = GetPersonenStringFromFullRow (NewFullPerson);
			PersonenListBox.Items.Add (NewEntry);
			NewEntry.BringIntoView ();
			PersonenListBox.SelectedItem = NewEntry;
			return PersonenIDToCreate;
			}
開發者ID:heinzsack,項目名稱:DEV,代碼行數:20,代碼來源:SelectPersonen.xaml.cs


注:本文中的System.Windows.Controls.ListBoxItem.BringIntoView方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。