本文整理汇总了C#中System.Windows.Input.TraversalRequest类的典型用法代码示例。如果您正苦于以下问题:C# TraversalRequest类的具体用法?C# TraversalRequest怎么用?C# TraversalRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TraversalRequest类属于System.Windows.Input命名空间,在下文中一共展示了TraversalRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: OnPreviewKeyDown
private static void OnPreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
if (GetFocusNext((UIElement)sender))
{
TraversalRequest tRequest = new TraversalRequest(FocusNavigationDirection.Next);
UIElement keyboardFocus = Keyboard.FocusedElement as UIElement;
if (keyboardFocus != null)
{
keyboardFocus.MoveFocus(tRequest);
}
}
else if (GetFocusedControl((UIElement)sender) != null)
{
var ctl = GetFocusedControl((UIElement)sender);
if (ctl != null && ctl is IInputElement)
{
FocusManager.SetFocusedElement(ctl, (IInputElement)ctl);
}
}
e.Handled = true;
}
}
开发者ID:nagyistoce,项目名称:ArchitectureCampSample,代码行数:25,代码来源:EnterToTabBehavior.cs
示例2: TabIntoCore
protected override Boolean TabIntoCore(TraversalRequest request)
{
if (this.m_GotFocus != null)
{
this.m_GotFocus(this, EventArgs.Empty);
}
return true;
}
开发者ID:Happy-Ferret,项目名称:dotgecko,代码行数:8,代码来源:WebBrowserElement.cs
示例3: OnPreviewMouseLeftButtonDown
private void OnPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
var row = sender as DataGridRow;
row.Focusable = true;
bool focused = row.Focus();
TraversalRequest request = new TraversalRequest(FocusNavigationDirection.Next);
UIElement elementWithFocus = Keyboard.FocusedElement as UIElement;
if (elementWithFocus != null)
elementWithFocus.MoveFocus(request);
}
开发者ID:ponraja,项目名称:Regex-Builder,代码行数:10,代码来源:LibraryView.xaml.cs
示例4: Window_Loaded
private void Window_Loaded(object sender, RoutedEventArgs e)
{
FocusManager.SetFocusedElement(this, tb);
TraversalRequest tRequest = new TraversalRequest(FocusNavigationDirection.Next);
UIElement keyboardFocus = Keyboard.FocusedElement as UIElement;
if (keyboardFocus != null)
{
keyboardFocus.MoveFocus(tRequest);
}
}
开发者ID:madd0,项目名称:MoveToFolder,代码行数:11,代码来源:FolderSelectionWindow.xaml.cs
示例5: KeyUp_TextBox
void KeyUp_TextBox(object sender, KeyEventArgs e)
{
var tb = e.OriginalSource as TextBox;
if (tb == null)
{
return;
}
if (e.Key == Key.Return || e.Key == Key.Enter)
{
var req = new TraversalRequest(FocusNavigationDirection.Next);
tb.MoveFocus(req);
}
}
开发者ID:mrange,项目名称:WordFinder,代码行数:14,代码来源:MainWindow.xaml.cs
示例6: OnMoveFocus
private void OnMoveFocus(object sender, RoutedEventArgs e)
{
// Creating a FocusNavigationDirection object and setting it to a
// local field that contains the direction selected.
var focusDirection = _focusMoveValue;
// MoveFocus takes a TraveralReqest as its argument.
var request = new TraversalRequest(focusDirection);
// Gets the element with keyboard focus.
var elementWithFocus = Keyboard.FocusedElement as UIElement;
// Change keyboard focus.
elementWithFocus?.MoveFocus(request);
}
开发者ID:ClemensT,项目名称:WPF-Samples,代码行数:15,代码来源:MainWindow.cs
示例7: MoveToNextUIElement
private static void MoveToNextUIElement(KeyEventArgs e)
{
// Creating a FocusNavigationDirection object and setting it to a
// local field that contains the direction selected.
const FocusNavigationDirection focusDirection = FocusNavigationDirection.Next;
// MoveFocus takes a TraveralReqest as its argument.
var request = new TraversalRequest(focusDirection);
// Gets the element with keyboard focus.
var elementWithFocus = Keyboard.FocusedElement as UIElement;
// Change keyboard focus.
if (elementWithFocus == null) return;
if (elementWithFocus.MoveFocus(request)) e.Handled = true;
}
开发者ID:starlest,项目名称:PJSM.ERP,代码行数:16,代码来源:PurchaseView.xaml.cs
示例8: CreateDynamicEditingElement
protected override FrameworkElement CreateDynamicEditingElement(Entity curEntity)
{
var value = this.PropertyValue;
//支持两种属性类型:DateRange,String,所以这里使用这个变量进行分辨
var useDateRangeType = this.Meta.PropertyMeta.Runtime.PropertyType == typeof(DateRange);
var range = useDateRangeType ?
new DateRange(value as DateRange) :
DateRange.Parse(value != null ? value as string : string.Empty);
var control = new DateRangePropertyEditorControl(range);
control.Confirm += (oo, ee) =>
{
if (useDateRangeType)
{
var raw = value as DateRange;
raw.BeginValue = ee.Range.BeginValue;
raw.EndValue = ee.Range.EndValue;
}
else
{
this.PropertyValue = ee.Range.ToString();
}
};
control.KeyDown += (oo, ee) =>
{
if (ee.Key == Key.Enter)
{
FocusNavigationDirection focusDirection = FocusNavigationDirection.Next;
TraversalRequest request = new TraversalRequest(focusDirection);
control.MoveFocus(request);
}
};
this.AddReadOnlyComponent(control);
this.SetAutomationElement(control);
return control;
}
开发者ID:569550384,项目名称:Rafy,代码行数:42,代码来源:DateRangePropertyEditor.cs
示例9: Merlin_DataContextChanged
void Merlin_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (e.NewValue is QueryEditorModel)
{
QueryEditorModel model = e.NewValue as QueryEditorModel;
model.BuildStartCommand.CanExecuteTargets += () => true;
model.BuildStartCommand.ExecuteTargets += (o) =>
{
// Source doesn't get updated for we need to move the
// focus out for the bind to the source.
TraversalRequest request = new TraversalRequest(FocusNavigationDirection.Next);
UIElement element = Keyboard.FocusedElement as UIElement;
if (element != null)
{
element.MoveFocus(request);
element.Focus();
}
};
}
}
开发者ID:aelij,项目名称:svcperf,代码行数:20,代码来源:Merlin.xaml.cs
示例10: Find_KeyUp
private void Find_KeyUp(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
ComboBox comboBox = ((ComboBox)sender);
if (comboBox.Text.Length > 0 && comboBox.Items != null && (comboBox.Items.Count == 0 || (string)comboBox.Items[0] != comboBox.Text))
{
comboBox.Items.Insert(0, comboBox.Text);
}
TraversalRequest tRequest = new TraversalRequest(FocusNavigationDirection.Next);
UIElement keyboardFocus = Keyboard.FocusedElement as UIElement;
if (keyboardFocus != null)
{
keyboardFocus.MoveFocus(tRequest);
}
}
else
{
mainWindow.FindNextStringOnPage(FindText.Text, false, true, this.MatchCase.IsChecked ?? true, this.RegexFind.IsChecked ?? true);
}
}
开发者ID:kjk,项目名称:kjkpub,代码行数:21,代码来源:FindAndReplace.xaml.cs
示例11: TextBox_TextChanged
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
{
TextBox textbox = (TextBox)sender;
byte octet;
if(!byte.TryParse(textbox.Text,out octet))
{
textbox.Text = "";
}
else
{
if (textbox.Text.Length == 3)
{
TraversalRequest request = new TraversalRequest(FocusNavigationDirection.Next);
request.Wrapped = true;
textbox.MoveFocus(request);
}
}
if(firstOctet.Text!="" && secondOctet.Text!="" && thirdOctet.Text!="" && fourthOctet.Text != "")
{
calculate();
}
IPCalculation ipc = new IPCalculation(null, 1);
}
开发者ID:subnetz,项目名称:IPCalc,代码行数:23,代码来源:MainWindow.xaml.cs
示例12: Weekdays_PreviewKeyDown
private void Weekdays_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
Action<FocusNavigationDirection> moveFocus = focusDirection =>
{
e.Handled = true;
var request = new TraversalRequest(focusDirection);
var focusedElement = Keyboard.FocusedElement as CheckBox;
if (((string)focusedElement.Content == "SU" && request.FocusNavigationDirection == FocusNavigationDirection.Next))
{
Monday.Focus();
}
else if (((string)focusedElement.Content == "MO" && request.FocusNavigationDirection == FocusNavigationDirection.Previous))
{
Sunday.Focus();
}
else
{
focusedElement.MoveFocus(request);
}
};
if (e.Key == Key.Down)
{
moveFocus(FocusNavigationDirection.Previous);
}
else if (e.Key == Key.Up)
{
moveFocus(FocusNavigationDirection.Next);
}
if (e.Key == Key.Tab)
{
Sunday.Focus();
}
}
开发者ID:Aishaj,项目名称:AGC.v3,代码行数:36,代码来源:EventsCreateView.xaml.cs
示例13: TabIntoCore
bool IKeyboardInputSink.TabInto(TraversalRequest request)
{
return TabIntoCore(request);
}
开发者ID:JazzFisch,项目名称:AnotherCombatManager,代码行数:4,代码来源:RedirectedHwndHost.cs
示例14: OnTabKeyDown
/// <summary>
/// Called when the tab key is pressed to perform focus navigation.
/// </summary>
private void OnTabKeyDown(KeyEventArgs e)
{
// When the end-user uses the keyboard to tab to another cell while the current cell
// is in edit-mode, then the next cell should enter edit mode in addition to gaining
// focus. There is no way to detect this from the focus change events, so the cell
// is going to handle the complete operation manually.
// The standard focus change method is being called here, so even if focus moves
// to something other than a cell, focus should land on the element that it would
// have landed on anyway.
DataGridCell currentCellContainer = CurrentCellContainer;
if (currentCellContainer != null)
{
bool wasEditing = currentCellContainer.IsEditing;
bool previous = ((e.KeyboardDevice.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift);
// Start navigation from the current focus to allow moveing focus on other focusable elements inside the cell
UIElement startElement = Keyboard.FocusedElement as UIElement;
ContentElement startContentElement = (startElement == null) ? Keyboard.FocusedElement as ContentElement : null;
if ((startElement != null) || (startContentElement != null))
{
e.Handled = true;
FocusNavigationDirection direction = previous ? FocusNavigationDirection.Previous : FocusNavigationDirection.Next;
TraversalRequest request = new TraversalRequest(direction);
// Move focus to the the next or previous tab stop.
if (((startElement != null) && startElement.MoveFocus(request)) ||
((startContentElement != null) && startContentElement.MoveFocus(request)))
{
// If focus moved to the cell while in edit mode - keep navigating to the previous cell
if (wasEditing && previous && Keyboard.FocusedElement == currentCellContainer)
{
currentCellContainer.MoveFocus(request);
}
// In case of grouping if a row level commit happened due to
// the previous focus change, the container of the row gets
// removed from the visual tree by the CollectionView,
// but we still hang on to a cell of that row, which will be used
// by the call to SelectAndEditOnFocusMove. Hence re-establishing the
// focus appropriately in such cases.
if (IsGrouping && wasEditing)
{
DataGridCell newCell = GetCellForSelectAndEditOnFocusMove();
if (newCell != null &&
newCell.RowDataItem == currentCellContainer.RowDataItem)
{
DataGridCell realNewCell = TryFindCell(ItemInfoFromContainer(newCell.RowOwner), newCell.Column);
// Forcing an UpdateLayout since the generation of the new row
// container which was removed earlier is done in measure.
if (realNewCell == null)
{
UpdateLayout();
realNewCell = TryFindCell(ItemInfoFromContainer(newCell.RowOwner), newCell.Column);
}
if (realNewCell != null && realNewCell != newCell)
{
realNewCell.Focus();
}
}
}
// When doing TAB and SHIFT+TAB focus movement, don't confuse the selection
// code, which also relies on SHIFT to know whether to extend selection or not.
SelectAndEditOnFocusMove(e, currentCellContainer, wasEditing, /* allowsExtendSelect = */ false, /* ignoreControlKey = */ true);
}
}
}
}
开发者ID:JianwenSun,项目名称:cc,代码行数:74,代码来源:DataGrid.cs
示例15: OnArrowKeyDown
//.........这里部分代码省略.........
}
else
{
nextDisplayIndex--;
while (nextDisplayIndex >= 0)
{
DataGridColumn column = ColumnFromDisplayIndex(nextDisplayIndex);
if (column.IsVisible)
{
break;
}
nextDisplayIndex--;
}
if (nextDisplayIndex < 0)
{
if (keyboardNavigationMode == KeyboardNavigationMode.Cycle)
{
nextDisplayIndex = InternalColumns.LastVisibleDisplayIndex;
}
else if (keyboardNavigationMode == KeyboardNavigationMode.Contained)
{
DependencyObject nextFocusTarget = keyboardNavigation.PredictFocusedElement(currentCellContainer, KeyToTraversalDirection(rtlKey),
treeViewNavigation:false, considerDescendants:false);
if (nextFocusTarget != null && keyboardNavigation.IsAncestorOfEx(this, nextFocusTarget))
{
Keyboard.Focus(nextFocusTarget as IInputElement);
}
return;
}
else // Continue, Local, None - move focus out of the datagrid
{
MoveFocus(new TraversalRequest(e.Key == Key.Left ? FocusNavigationDirection.Left : FocusNavigationDirection.Right));
return;
}
}
}
break;
case Key.Right:
if (controlModifier)
{
nextDisplayIndex = Math.Max(0, InternalColumns.LastVisibleDisplayIndex);
}
else
{
nextDisplayIndex++;
int columnCount = Columns.Count;
while (nextDisplayIndex < columnCount)
{
DataGridColumn column = ColumnFromDisplayIndex(nextDisplayIndex);
if (column.IsVisible)
{
break;
}
nextDisplayIndex++;
}
if (nextDisplayIndex >= Columns.Count)
{
if (keyboardNavigationMode == KeyboardNavigationMode.Cycle)
{
nextDisplayIndex = InternalColumns.FirstVisibleDisplayIndex;
开发者ID:JianwenSun,项目名称:cc,代码行数:67,代码来源:DataGrid.cs
示例16: Window_PreviewMouseDown
private void Window_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
FocusNavigationDirection focusDirection = FocusNavigationDirection.Up; //可以是其他方向键.它是一个枚举值.
TraversalRequest request = new TraversalRequest(focusDirection);
txtSearch.MoveFocus(request);
}
开发者ID:CwjXFH,项目名称:dictionary-release,代码行数:6,代码来源:MainWindow.xaml.cs
示例17: TextBox_OnKeyDown
private void TextBox_OnKeyDown(object sender, KeyEventArgs e)
{
bool move = e.Key == Key.Enter | e.Key == Key.Up | e.Key == Key.Down;
bool up = e.Key == Key.Enter ? ( ( Keyboard.IsKeyDown( Key.LeftShift ) | Keyboard.IsKeyDown( Key.RightShift ) ) )
: e.Key == Key.Up;
if ( move )
{
// we need to delay this until after the text is changed
var box = sender as TextBox;
BindingExpression be = box.GetBindingExpression( TextBox.TextProperty );
be.UpdateSource();
// MoveFocus takes a TraversalRequest as its argument.
TraversalRequest request = new TraversalRequest(
up ? FocusNavigationDirection.Previous : FocusNavigationDirection.Next );
// Gets the element with keyboard focus.
UIElement elementWithFocus = Keyboard.FocusedElement as UIElement;
// Change keyboard focus.
if ( elementWithFocus != null )
{
elementWithFocus.MoveFocus( request );
}
}
}
开发者ID:Cocotus,项目名称:XTMF,代码行数:25,代码来源:LinkedParameterDisplay.xaml.cs
示例18: TabInto
internal void TabInto(bool forward)
{
TraversalRequest tr = new TraversalRequest(
forward ? FocusNavigationDirection.First : FocusNavigationDirection.Last);
MoveFocus(tr);
}
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:6,代码来源:RootBrowserWindow.cs
示例19:
bool IKeyboardInputSite.OnNoMoreTabStops(TraversalRequest request)
{
return Browser.TabOut(request.FocusNavigationDirection == FocusNavigationDirection.Next);
// i. Tabbing-in is handled by ApplicationProxyInternal.
}
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:5,代码来源:RootBrowserWindow.cs
示例20: OnArrowKeyDown
//.........这里部分代码省略.........
switch (rtlKey)
{
case Key.Left:
if (controlModifier)
{
nextDisplayIndex = InternalColumns.FirstVisibleDisplayIndex;
}
else
{
nextDisplayIndex--;
while (nextDisplayIndex >= 0)
{
DataGridColumn column = ColumnFromDisplayIndex(nextDisplayIndex);
if (column.IsVisible)
{
break;
}
nextDisplayIndex--;
}
if (nextDisplayIndex < 0)
{
if (keyboardNavigationMode == KeyboardNavigationMode.Cycle)
{
nextDisplayIndex = InternalColumns.LastVisibleDisplayIndex;
}
else if (keyboardNavigationMode == KeyboardNavigationMode.Contained)
{
return;
}
else // Continue, Local, None - move focus out of the datagrid
{
MoveFocus(new TraversalRequest(e.Key == Key.Left ? FocusNavigationDirection.Left : FocusNavigationDirection.Right));
return;
}
}
}
break;
case Key.Right:
if (controlModifier)
{
nextDisplayIndex = Math.Max(0, InternalColumns.LastVisibleDisplayIndex);
}
else
{
nextDisplayIndex++;
int columnCount = Columns.Count;
while (nextDisplayIndex < columnCount)
{
DataGridColumn column = ColumnFromDisplayIndex(nextDisplayIndex);
if (column.IsVisible)
{
break;
}
nextDisplayIndex++;
}
if (nextDisplayIndex >= Columns.Count)
{
if (keyboardNavigationMode == KeyboardNavigationMode.Cycle)
{
nextDisplayIndex = InternalColumns.FirstVisibleDisplayIndex;
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:67,代码来源:DataGrid.cs
注:本文中的System.Windows.Input.TraversalRequest类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论