// Token: 0x06002D45 RID: 11589 RVA: 0x000CC594 File Offset: 0x000CA794 internal static void NavigateToElement(object ElementHost, string elementID) { FixedPage fixedPage = null; FrameworkElement frameworkElement = ((IFixedNavigate)ElementHost).FindElementByID(elementID, out fixedPage) as FrameworkElement; if (frameworkElement != null) { if (frameworkElement is FixedPage) { frameworkElement.BringIntoView(); return; } frameworkElement.BringIntoView(frameworkElement.VisualContentBounds); } }
public void BringListChildIntoView(FrameworkElement inList, object inItem) { // Finds the item in the list FrameworkElement listItem = null; switch (inList) { case ListView listView: listItem = listView.ItemContainerGenerator.ContainerFromItem(inItem) as FrameworkElement; break; case ListBox listBox: listItem = listBox.ItemContainerGenerator.ContainerFromItem(inItem) as FrameworkElement; break; case ItemsControl itemsControl: listItem = itemsControl.ItemContainerGenerator.ContainerFromItem(inItem) as FrameworkElement; break; default: throw new ArgumentOutOfRangeException($"The list type {inList.GetType()} is not supported as a list container."); } if (listItem != null) { listItem.Dispatcher.Invoke(() => { listItem.BringIntoView(); }); } }
/// <summary> /// Find the first UIElement that has validation failure /// starting from the given item and attempt to show it. /// </summary> /// <returns>Returns the item found or null.</returns> public static UIElement ShowFirstInvalid(this UIElement item) { UIElement itemFound = item.FindFirstInvalid(); if (itemFound != null) { // Attempt to find whether the element is inside a TabItem. for ( DependencyObject parent = LogicalTreeHelper.GetParent(itemFound); parent != null; parent = LogicalTreeHelper.GetParent(parent)) { TabItem tabItem = parent as TabItem; if (tabItem != null) { tabItem.IsSelected = true; } } FrameworkElement element = itemFound as FrameworkElement; if (element != null) { element.BringIntoView(); } itemFound.Focus(); } return(itemFound); }
// Find the closest IsSelectable parent and select it. Don't mess with focus. // private void Select(DependencyObject visualSource) { if (visualSource != null) { FrameworkElement selection = PropertySelection.FindParentSelectionStop <FrameworkElement>(visualSource); if (selection != _selection) { // Unselect anything that was selected previously if (_selection != null) { PropertySelection.SetIsSelected(_selection, false); } _selection = selection; // Select whatever we need to select now if (_selection != null) { PropertySelection.SetIsSelected(_selection, true); // Bring the full PropertyContainer into view, if one exists FrameworkElement focusableElement = VisualTreeUtils.FindFocusableElement <FrameworkElement>(_selection) ?? _selection; FrameworkElement parentPropertyContainer = VisualTreeUtils.FindVisualAncestor <PropertyContainer>(focusableElement); FrameworkElement bringIntoViewElement = parentPropertyContainer ?? focusableElement; bringIntoViewElement.BringIntoView(); // As soon as the user manually selects a property, automatically switch to Sticky mode _selectionMode = PropertySelectionMode.Sticky; } } } }
// Token: 0x060072C7 RID: 29383 RVA: 0x0020F7F0 File Offset: 0x0020D9F0 internal static void BringRectIntoViewMinimally(ITextView textView, Rect rect) { IScrollInfo scrollInfo = textView.RenderScope as IScrollInfo; if (scrollInfo != null) { Rect rect2 = new Rect(scrollInfo.HorizontalOffset, scrollInfo.VerticalOffset, scrollInfo.ViewportWidth, scrollInfo.ViewportHeight); rect.X += rect2.X; rect.Y += rect2.Y; double num = ScrollContentPresenter.ComputeScrollOffsetWithMinimalScroll(rect2.Left, rect2.Right, rect.Left, rect.Right); double num2 = ScrollContentPresenter.ComputeScrollOffsetWithMinimalScroll(rect2.Top, rect2.Bottom, rect.Top, rect.Bottom); scrollInfo.SetHorizontalOffset(num); scrollInfo.SetVerticalOffset(num2); FrameworkElement frameworkElement = FrameworkElement.GetFrameworkParent(textView.RenderScope) as FrameworkElement; if (frameworkElement != null) { if (scrollInfo.ViewportWidth > 0.0) { rect.X -= num; } if (scrollInfo.ViewportHeight > 0.0) { rect.Y -= num2; } frameworkElement.BringIntoView(rect); return; } } else { ((FrameworkElement)textView.RenderScope).BringIntoView(rect); } }
//05Sept2019 exact copy from OutputWindow.xaml. Not Sure if in future they will differ private void tvi_Selected(object sender, RoutedEventArgs e) { FrameworkElement fe = sender as FrameworkElement; TreeViewItem tvi = fe as TreeViewItem; ((tvi.Header as StackPanel).Children[0] as CheckBox).IsChecked = true; FrameworkElement tag = fe.Tag as FrameworkElement; //scrollviewer.BringIntoView(tag.GetVisualBounds(this)); IAUControl control = tag as IAUControl; ////05Jun2013 control.outerborderthickness = new Thickness(1); string navtreeselcom = confService.GetConfigValueForKey("navtreeselectedcol");//23nov2012 byte red = byte.Parse(navtreeselcom.Substring(3, 2), NumberStyles.HexNumber); byte green = byte.Parse(navtreeselcom.Substring(5, 2), NumberStyles.HexNumber); byte blue = byte.Parse(navtreeselcom.Substring(7, 2), NumberStyles.HexNumber); Color c = Color.FromArgb(255, red, green, blue); control.bordercolor = new SolidColorBrush(c);// (Colors.Gold);//05Jun2013 control.outerborderthickness = new Thickness(2); //Rect rct = new Rect(1, 1, tag.ActualWidth,tag.ActualHeight); tag.BringIntoView(); //treeview leaf node will appear selected as oppose to Focus() e.Handled = true; //tag.Focus(); //(fe as TreeViewItem).Foreground = Brushes.LightBlue; //17Jan2013 //ScrollViewer sv = this.scrollviewer; //sv.ScrollToVerticalOffset(NavTree.Items.IndexOf(tag)); //ScrollViewer myScrollViewer = (ScrollViewer)NavTree.Template.FindName("_tv_scrollviewer_", NavTree); //myScrollViewer.ScrollToHome(); }
private void HandleBringIntoView(RequestBringIntoViewEventArgs e) { TreeViewItem parent = ParentTreeViewItem; while (parent != null) { if (!parent.IsExpanded) { parent.SetCurrentValueInternal(IsExpandedProperty, BooleanBoxes.TrueBox); } parent = parent.ParentTreeViewItem; } // See FrameworkElement.BringIntoView() comments //dmitryt, if (e.TargetRect.IsEmpty) { FrameworkElement header = HeaderElement; if (header != null) { e.Handled = true; header.BringIntoView(); } else { // Header is not generated yet. Could happen if BringIntoView is called on container before layout. Try later. Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new DispatcherOperationCallback(BringItemIntoView), null); } } }
private void HandleBringIntoView(RequestBringIntoViewEventArgs e) { TreeViewItem parent = ParentTreeViewItem; while (parent != null) { if (!parent.IsExpanded) { parent.SetCurrentValueInternal(IsExpandedProperty, BooleanBoxes.TrueBox); } parent = parent.ParentTreeViewItem; } // See FrameworkElement.BringIntoView() comments //dmitryt, bug 1126518. On new/updated elements RenderSize isn't yet computed //so we need to postpone the rect computation until layout is done. //this is accomplished by passing Empty rect here and then asking for RenderSize //in IScrollInfo when it actually executes an async MakeVisible command. if (e.TargetRect.IsEmpty) { FrameworkElement header = HeaderElement; if (header != null) { e.Handled = true; header.BringIntoView(); } else { // Header is not generated yet. Could happen if BringIntoView is called on container before layout. Try later. Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new DispatcherOperationCallback(BringItemIntoView), null); } } }
public void ScrollIntoView(object item) { FrameworkElement o = this.ItemContainerGenerator.ContainerFromItem(item) as FrameworkElement; if (o != null) { o.BringIntoView(); } }
internal static void BringIntoViewKeyboardFocusedElement() { FrameworkElement frameworkElement = Keyboard.FocusedElement as FrameworkElement; if (frameworkElement != null) { frameworkElement.BringIntoView(); } }
public void BringItemIntoView(object item) { MultiSelectTreeViewItem node = GetTreeViewItemsFor(new List <object> { item }).First(); FrameworkElement itemContent = (FrameworkElement)node.Template.FindName("headerBorder", node); itemContent.BringIntoView(); }
//25Feb2015 exact copy of AddAnalyisFromFile from OutputWindow.xaml Not Sure if in future they will differ public void showOutput(string fullpathfilename) { FrameworkElement lastElement = null;//25Feb2015 AnalyticsData analysisdata = null; List <SessionOutput> allAnalysis = null; BSkyOutputGenerator bsog = new BSkyOutputGenerator(); allAnalysis = bsog.GenerateOutput(fullpathfilename); if (allAnalysis == null) { return; } foreach (SessionOutput so in allAnalysis) { bool isRSession = so.isRSessionOutput; if (isRSession) { SessionItem = new TreeViewItem();//15Nov2013 SessionItem.Header = so.NameOfSession; SessionItem.IsExpanded = true; } double extraspaceinbeginning = 0; if (mypanel.Children.Count > 0)//if its not the first item on panel { extraspaceinbeginning = 10; } foreach (CommandOutput co in so) { analysisdata = new AnalyticsData(); //blank entry. analysisdata.Output = co; //saving reference. analysisdata.AnalysisType = co.NameOfAnalysis; //For Parent Node name 02Aug2012 foreach (DependencyObject obj in co) { FrameworkElement element = obj as FrameworkElement; element.Margin = new Thickness(10, 2 + extraspaceinbeginning, 0, 2);; mypanel.Children.Add(element); extraspaceinbeginning = 0; lastElement = element; } PopulateTree(co, isRSession); outputDataList.Add(analysisdata); } if (isRSession) { NavTree.Items.Add(SessionItem);//15Nov2013 } } //25Feb2015 bring last into focus if (lastElement != null) { lastElement.BringIntoView(); } }
/// <summary> /// Try to update the scroll viewers to keep selected item visible... /// </summary> /// <param name="palette"></param> /// <param name="thumb"></param> private void event_ThumbnailSelected(Palette palette, Thumbnail thumb) { // Disgusting, and doesn't work with a virtualising stack panel because there's no UI element generated if it's not visible! FrameworkElement element = Thumbnails.ItemContainerGenerator.ContainerFromItem(thumb) as FrameworkElement; if (element != null) { element.BringIntoView(); } }
private static void OnScrollIntoViewChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { FrameworkElement element = d as FrameworkElement; if ((bool)e.NewValue) { element.BringIntoView(); element.Focus(); } }
// Token: 0x06005929 RID: 22825 RVA: 0x0018A3F0 File Offset: 0x001885F0 private object BringItemIntoView(object args) { FrameworkElement headerElement = this.HeaderElement; if (headerElement != null) { headerElement.BringIntoView(); } return(null); }
// Logic should'nt be same as in OutputWindow.xaml.cs because this is only meant for displaying output/// void tvi_Selected(object sender, RoutedEventArgs e) { FrameworkElement fe = sender as FrameworkElement; FrameworkElement tag = fe.Tag as FrameworkElement; IAUControl control = tag as IAUControl; control.bordercolor = new SolidColorBrush(Colors.Gold); //05Jun2013 tag.BringIntoView(); //treeview leaf node will appear selected as oppose to Focus() }
private void OnTreeViewItemSelected(object sender, RoutedEventArgs e) { e.Handled = true; //to prevent Parent item from being selected! FrameworkElement selectedItem = sender as FrameworkElement; if (selectedItem != null) { selectedItem.BringIntoView(); } }
// Taken from https://kiwigis.blogspot.com/2010/12/how-to-add-scrollintoview-to.html public static void ScrollIntoView( this ItemsControl control, object item) { FrameworkElement framework = control.ItemContainerGenerator.ContainerFromItem(item) as FrameworkElement; if (framework == null) { return; } framework.BringIntoView(); }
private static void OnScrollIntoViewWhenLoadedPropertyChanged(DependencyObject target, DependencyPropertyChangedEventArgs e) { if (!(bool)target.GetValue(CategoryContainer.ScrollIntoViewWhenLoadedProperty)) { return; } FrameworkElement frameworkElement = target as FrameworkElement; if (frameworkElement == null || !frameworkElement.IsLoaded) { return; } frameworkElement.BringIntoView(); }
public static void Focus(MultiSelectTreeViewItem element, bool bringIntoView = false) { //System.Diagnostics.Debug.WriteLine("FocusHelper focusing " + (bringIntoView ? "[into view] " : "") + element.DataContext); FocusCore(element); if (bringIntoView) { FrameworkElement itemContent = (FrameworkElement)element.Template.FindName("headerBorder", element); if (itemContent != null) // May not be rendered yet... { itemContent.BringIntoView(); } } }
private static void ClickControl_ScrollIntoViewPropertyInvalidated(DependencyObject target, DependencyPropertyChangedEventArgs e) { if (!(bool)target.GetValue(ClickControl.ScrollIntoViewProperty)) { return; } FrameworkElement frameworkElement = target as FrameworkElement; if (frameworkElement == null) { return; } frameworkElement.BringIntoView(); }
private bool BringAssetItemIntoView(string itemsControlName) { if (this.Template != null) { object obj = (object)this.SelectedAsset; FrameworkElement frameworkElement = (this.Template.FindName(itemsControlName, (FrameworkElement)this) as ItemsControl).ItemContainerGenerator.ContainerFromItem(obj) as FrameworkElement; if (frameworkElement != null) { frameworkElement.BringIntoView(); return(true); } } return(false); }
public void ScrollIntoView() { if (_wasScrolledIntoView) { return; } ItemsControl control = MainWindow.ItemsControl; FrameworkElement framework = control.ItemContainerGenerator.ContainerFromItem(this.AssociatedObject.DataContext) as FrameworkElement; if (framework == null) { return; } framework.BringIntoView(); }
/// <summary> /// Fire BringinToView event on the element ID. /// </summary> /// <param name="ElementHost">The host document of element ID, call any one implents IFixedNavigate</param> /// <param name="elementID"></param> internal static void NavigateToElement(object ElementHost, string elementID) { FixedPage rootFixedPage = null; FrameworkElement targetElement = null; targetElement = ((IFixedNavigate)ElementHost).FindElementByID(elementID, out rootFixedPage) as FrameworkElement; if (targetElement != null) { if (targetElement is FixedPage) { // // For fixedpage, we only need to scroll to page position. // targetElement.BringIntoView(); } else { //Just passing in raw rect of targetElement. Let DocumentViewer/Grid handle transforms targetElement.BringIntoView(targetElement.VisualContentBounds); } } return; }
private void MainItem_Selected(object sender, RoutedEventArgs e) { FrameworkElement fe = sender as FrameworkElement; FrameworkElement tag = fe.Tag as FrameworkElement; IAUControl control = tag as IAUControl; string navtreeselcom = confService.GetConfigValueForKey("navtreeselectedcol");//23nov2012 byte red = byte.Parse(navtreeselcom.Substring(3, 2), NumberStyles.HexNumber); byte green = byte.Parse(navtreeselcom.Substring(5, 2), NumberStyles.HexNumber); byte blue = byte.Parse(navtreeselcom.Substring(7, 2), NumberStyles.HexNumber); Color c = Color.FromArgb(255, red, green, blue); control.bordercolor = new SolidColorBrush(c); // (Colors.Gold);//05Jun2013 control.outerborderthickness = new Thickness(2); tag.BringIntoView(); //treeview leaf node will appear selected as oppose to Focus() }
private void BringElementToView(FrameworkElement element, EasingMode easeMode) { if (element == null) { return; } ScrollViewer scrollViewer = element.FindAncestorByType <ScrollViewer>(); if (scrollViewer != null) { Point relativePoint = element.TransformToAncestor(scrollViewer).Transform(new Point(0, 0)); ScrollToPosition(scrollViewer, relativePoint.X, relativePoint.Y, easeMode); } else { element.BringIntoView(); } }
private static void ClickControl_DelayedScrollIntoViewPropertyInvalidated(DependencyObject target, DependencyPropertyChangedEventArgs e) { if (!(bool)target.GetValue(ClickControl.DelayedScrollIntoViewProperty)) { return; } FrameworkElement element = target as FrameworkElement; if (element == null) { return; } UIThreadDispatcher.Instance.BeginInvoke(DispatcherPriority.Render, (Action)(() => { element.BringIntoView(); element.SetValue(ClickControl.DelayedScrollIntoViewProperty, (object)false); })); }
private void BringIntoViewOverride(RequestBringIntoViewEventArgs e) { ExpandAncestors(); // Only bring header into view. Ignore children. if (e.TargetRect.IsEmpty) { if (_header != null) { e.Handled = true; _header.BringIntoView(); } else { // Retry when loaded. Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(() => _header?.BringIntoView())); } } }
// Token: 0x06005928 RID: 22824 RVA: 0x0018A374 File Offset: 0x00188574 private void HandleBringIntoView(RequestBringIntoViewEventArgs e) { for (TreeViewItem parentTreeViewItem = this.ParentTreeViewItem; parentTreeViewItem != null; parentTreeViewItem = parentTreeViewItem.ParentTreeViewItem) { if (!parentTreeViewItem.IsExpanded) { parentTreeViewItem.SetCurrentValueInternal(TreeViewItem.IsExpandedProperty, BooleanBoxes.TrueBox); } } if (e.TargetRect.IsEmpty) { FrameworkElement headerElement = this.HeaderElement; if (headerElement != null) { e.Handled = true; headerElement.BringIntoView(); return; } base.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new DispatcherOperationCallback(this.BringItemIntoView), null); } }
/// <summary> /// Helper method which scrolls item at given index into view. /// Can be used as a dispatcher operation. /// </summary> /// <param name="arg"></param> /// <returns></returns> private object ScrollContainerIntoView(object arg) { int index = (int)arg; FrameworkElement element = ItemContainerGenerator.ContainerFromIndex(index) as FrameworkElement; if (element != null) { element.BringIntoView(); // If there is a margin on TabHeader on the end, BringIntoView call // may not scroll to the end. Explicitly scroll to end in such cases. IScrollInfo scrollInfo = InternalItemsHost as IScrollInfo; if (scrollInfo != null) { ScrollViewer scrollViewer = scrollInfo.ScrollOwner; if (scrollViewer != null) { Ribbon ribbon = RibbonControlService.GetRibbon(this); if (ribbon != null) { int displayIndex = ribbon.GetTabDisplayIndexForIndex(index); if (displayIndex == 0) { // If this tab header is the first tab header displayed // then scroll to the left end. scrollViewer.ScrollToLeftEnd(); } else if (ribbon.GetTabIndexForDisplayIndex(displayIndex + 1) < 0) { // If this tab header is the last tab header displayed // then scroll to the right end. scrollViewer.ScrollToRightEnd(); } } } } } return(null); }