本文整理汇总了C#中System.Windows.Controls.Border.Events方法的典型用法代码示例。如果您正苦于以下问题:C# Border.Events方法的具体用法?C# Border.Events怎么用?C# Border.Events使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.Border
的用法示例。
在下文中一共展示了Border.Events方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnApplyTemplate
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
_border = GetTemplateChild("PART_Border") as Border;
_dropDown = GetTemplateChild("PART_DropDown") as Popup;
_lbDropDown = GetTemplateChild("PART_LBDropDown") as ListBox;
_arrowHost = GetTemplateChild("PART_ArrowHost") as Border;
_borderDropDown = GetTemplateChild("PART_BorderDropDown") as Border;
_upperLoadingBar = GetTemplateChild("PART_UpperLoadingBar") as LoadingBar;
_bottomLoadingBar = GetTemplateChild("PART_BottomLoadingBar") as LoadingBar;
SetDropDownLoadingIndicator();
_lbDropDown.ItemTemplate = DropDownItemTemplate;
var style = new Style(typeof(ListBoxItem), (Style)FindResource("lbAutocompleteTextBoxDropDownItemStyle"));
style.Setters.Add(new EventSetter(Mouse.PreviewMouseUpEvent, new MouseButtonEventHandler(lbDropDownItem_PreviewMouseButtonUp)));
style.Setters.Add(new EventSetter(Mouse.MouseMoveEvent, new MouseEventHandler(lbDropDownItem_MouseMove)));
_lbDropDown.ItemContainerStyle = style;
_border.CornerRadius = CornerRadius;
_lbDropDownItemMouseMoves
.DistinctUntilChanged(x => x.EventArgs.GetPosition(this))
.Subscribe(x => _lbDropDown.SelectedItem = x.Sender.Content);
var previewKeyDowns = Observable.FromEventPattern<KeyEventHandler, KeyEventArgs>(
h => PreviewKeyDown += h, h => PreviewKeyDown -= h);
previewKeyDowns.Where(x => x.EventArgs.Key == Key.Enter)
.Subscribe(x => AcceptItem(x.EventArgs));
var previewKeyDownsKeyDowns = previewKeyDowns.Where(x => x.EventArgs.Key == Key.Down);
previewKeyDownsKeyDowns.Where(_ => _dropDown.IsOpen).Subscribe(_ => MoveDown());
previewKeyDownsKeyDowns.Where(_ => !_dropDown.IsOpen).Subscribe(_ => OpenDropDownByArrowButtonOrKey());
previewKeyDowns.Where(x => x.EventArgs.Key == Key.Up).Subscribe(_ => MoveUp());
previewKeyDowns.Where(x => x.EventArgs.Key == Key.Escape).Subscribe(_ => CancelOrIgnore());
previewKeyDowns.Where(x => x.EventArgs.Key == Key.PageUp).Subscribe(_ => MovePageUp());
previewKeyDowns.Where(x => x.EventArgs.Key == Key.PageDown).Subscribe(_ => MovePageDown());
var downs = _arrowHost.Events().MouseLeftButtonDown
.Select(_ => Mouse.Captured)
.Do(_ => Mouse.Capture(_arrowHost));
var ups = _arrowHost.Events().MouseLeftButtonUp;
downs
.GroupJoin(ups, d => downs, u => Observable.Return(Unit.Default),
(d, us) => ups.Take(1).Select(_ => d))
.Merge()
.Do(RestoreMouseCapture)
.Subscribe(_ => OpenDropDownByArrowButtonOrKey());
_dropDown.Closed += _dropDown_Closed;
_dropDown.Opened += dropDown_Opened;
LostFocus += AutocompleteTextBox_LostFocus;
}