本文整理汇总了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();
}
}
示例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;
}
}
示例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;
}