本文整理汇总了C#中System.Windows.Controls.ListViewItem.FindDescendant方法的典型用法代码示例。如果您正苦于以下问题:C# ListViewItem.FindDescendant方法的具体用法?C# ListViewItem.FindDescendant怎么用?C# ListViewItem.FindDescendant使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.ListViewItem
的用法示例。
在下文中一共展示了ListViewItem.FindDescendant方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StartEditing
private static void StartEditing(ListView list, ListViewItem item, DocumentGroup group, Action<TextBox, bool> endEditingFn)
{
var edit = item.FindDescendant<TextBox>();
var visibility = Observable.FromEventPattern<DependencyPropertyChangedEventArgs>(edit, "IsVisibleChanged");
var disposables = new CompositeDisposable();
visibility.Where(re => re.EventArgs.NewValue as bool? == false)
.Take(1)
.Subscribe(re => disposables.Dispose());
visibility.Where(ivc => ivc.EventArgs.NewValue as bool? == true)
.Take(1)
.Subscribe(re =>
{
edit.SelectionStart = 0;
edit.SelectionLength = edit.Text.Length;
edit.Focus();
});
disposables.Add(Observable.FromEventPattern<RoutedEventArgs>(edit, "LostFocus")
.Take(1)
.Subscribe(re => endEditingFn(edit, false)));
disposables.Add(Observable.FromEventPattern<KeyEventArgs>(edit, "PreviewKeyUp")
.Where(re => re.EventArgs.Key == Key.Escape || re.EventArgs.Key == Key.Enter)
.Take(1)
.Subscribe(re =>
{
re.EventArgs.Handled = true;
endEditingFn(edit, re.EventArgs.Key == Key.Escape);
}));
disposables.Add(Observable.FromEventPattern<MouseEventArgs>(list, "MouseLeftButtonDown")
.Take(1)
.Subscribe(re => endEditingFn(edit, false)));
group.StartEditing();
}