protected override void OnPointerPressed(PointerRoutedEventArgs e) { base.OnPointerPressed(e); NavigationBarItem element = VenturaVisualTreeHelper.FindParent <NavigationBarItem>(e.OriginalSource as DependencyObject); if (element != null) { MenubarItem item = (MenubarItem)element.DataContext; bool was_dropped = element.IsDroppedDown; SetAllChildrenAsNotDropped(); if (was_dropped == false) { element.IsDroppedDown = true; DisplayMenuPanel?.Invoke(this, item); } else { HideMenuPanel?.Invoke(); } } }
protected override void OnGotFocus(RoutedEventArgs e) { FrameworkElement focussed_element = e.OriginalSource as FrameworkElement; if (focussed_element == null) { return; } //throw new Exception("should not happen"); bool focus_inside_smartpage = VenturaVisualTreeHelper.FindParent <SmartPagePresenter>(focussed_element) != null; FormField formfield = VenturaVisualTreeHelper.FindParent <FormField>(focussed_element); if (focus_inside_smartpage == false) { return; } if (_last_formfield != null) { _last_formfield.IsActive = false; _last_formfield = null; } if (formfield != null) { formfield.IsActive = true; _last_formfield = formfield; } if (focussed_element is InputBase inputcontrol) { string header = ""; if (formfield != null) { header = formfield.Header; } //_assistant.SetAssistantTo(header, inputcontrol.TextBox); } else if (focussed_element is TextBox textbox) { string header = ""; //if( textbox.h) //textbox.Header if (formfield != null) { header = formfield.Header; } //_assistant.SetAssistantTo(header, textbox); } }
public ValidatorItem(Expression <Func <T, object> > memberLambda, FrameworkElement control) { _kind = ValidatorItemKind.ViewModelProperty; _memberLambda = memberLambda; _property_name = LambdaHelper.GetMemberName(memberLambda.Body); if (control is FormField) { _control = null; _formfield = (FormField)control; } else { // FindParent returns null if not found. _control = control; _formfield = VenturaVisualTreeHelper.FindParent <FormField>(control); } }
//ContentPresenter _presenter; // https://stackoverflow.com/questions/1517743/in-wpf-how-can-i-determine-whether-a-control-is-visible-to-the-user protected override void OnApplyTemplate() { if (_initialized) { throw new System.Exception("only call once"); } base.OnApplyTemplate(); ScrutinizeItemTemplate(); _HeaderScrollViewer = (ScrollViewer)GetTemplateChild("HeaderScrollViewer"); _HyperGridHeader = (HyperGridHeader)GetTemplateChild("HeaderControl"); _HyperGridHeader.ItemsSource = this.Header; _MainGrid = (Grid)GetTemplateChild("MainGrid"); //_MainGrid.SizeChanged += MainGrid_SizeChanged; _ListView = (ListView)GetTemplateChild("ListView"); // Force the ListView to load it's template, so we can get a reference to the scrollviewer. _ListView.ApplyTemplate(); _scrollviewer = VenturaVisualTreeHelper.FindDescendant <ScrollViewer>(_ListView);; _scrollviewer.ViewChanged += ScrollViewer_ViewChanged; _ListView.SelectionChanged += ListView_SelectionChanged; //_ListView.PointerPressed += ListView_PointerPressed; _ListView.DoubleTapped += ListView_DoubleTapped; _ListView.SelectedIndex = this.SelectedIndex; _ListView.RegisterPropertyChangedCallback(ListView.SelectedItemProperty, new DependencyPropertyChangedCallback(ListView_SelectedItem_PropertyChanged)); //// Bind HyperGrid.SelectedIndex to _ListView.SelectedIndex etc... //Binding b1 = new Binding { Source = this, Path = new PropertyPath("SelectedIndex"), Mode = BindingMode.TwoWay }; //Binding b2 = new Binding { Source = this, Path = new PropertyPath("SelectedItem"), Mode = BindingMode.TwoWay }; //_ListView.SetBinding(ListView.SelectedIndexProperty, b1); //_ListView.SetBinding(ListView.SelectedItemProperty, b2); _initialized = true; }
// A click inside the FormField will result in the first focussable control to get focus. private void FormField_PointerPressed(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e) { var element = _smartscaler.Content as FrameworkElement; if (element == null) { return; } Control control = VenturaVisualTreeHelper.FindDescendant <Control>(element); if (control == null) { return; } control.Focus(FocusState.Programmatic); e.Handled = true; }
private void ListView_DoubleTapped(object sender, Windows.UI.Xaml.Input.DoubleTappedRoutedEventArgs e) { //var aa = VenturaVisualTreeHelper.FindParent<HyperGridPanel>(e.OriginalSource as DependencyObject); ListViewItem pressed_row = VenturaVisualTreeHelper.FindParent <ListViewItem>(e.OriginalSource as DependencyObject); if (pressed_row == null) { return; } //var event_args = new RowDoubleClickedEventArgs //{ // ItemIndex = -1, // pressed_row.GetIndex(); // Item = pressed_row.Content // pressed_row.DataContext; //}; //RowDoubleClicked?.Invoke(this, event_args); RowDoubleClick?.Invoke(this, new RoutedEventArgs()); }
public ValidatorItem(string validator_id, FrameworkElement control) { if (validator_id == null) { throw new ArgumentNullException(nameof(validator_id)); } _kind = ValidatorItemKind.ValidatorId; _validator_id = validator_id; if (control is FormField) { _control = null; _formfield = (FormField)control; } else { // FindParent returns null if not found. _control = control; _formfield = VenturaVisualTreeHelper.FindParent <FormField>(control); } }