/// <summary> /// IRangeValueProvider implementation. /// </summary> public void SetValue(double value) { var rangeSliderPrimitive = ElementTreeHelper.FindVisualDescendant <RangeSliderPrimitive>(this.SliderBase); if (rangeSliderPrimitive != null) { var currentValue = rangeSliderPrimitive.VisualSelection.End - rangeSliderPrimitive.VisualSelection.Start; if (this.hasMaximumDirection) { if (value > currentValue) { rangeSliderPrimitive.UpdateSelectionEnd(this.LargeChange, true); } else { rangeSliderPrimitive.UpdateSelectionStart(this.LargeChange, true); } } else { if (value > currentValue) { rangeSliderPrimitive.UpdateSelectionStart(-this.LargeChange, true); } else { rangeSliderPrimitive.UpdateSelectionEnd(-this.LargeChange, true); } } } }
private static void FocusBindingPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { if (DesignerProperties.GetIsInDesignMode(obj)) { return; } var control = (FrameworkElement)obj; if ((bool)args.NewValue) { if (control.Focusable) { control.Focus(); } else { if (!control.IsLoaded) { control.Loaded += Control_Loaded; } else { foreach (var child in ElementTreeHelper.FindVisualChildren <FrameworkElement>(control)) { if (child.Focusable && child.IsVisible) { child.Focus(); return; } } } } } }
/// <inheritdoc /> protected override IList <AutomationPeer> GetChildrenCore() { List <AutomationPeer> list = new List <AutomationPeer>(); IEnumerable <DependencyObject> childElements = ElementTreeHelper.EnumVisualDescendants(this.Owner, descendand => descendand is ChartElementPresenter); foreach (ChartElementPresenter child in childElements) { AutomationPeer item = FrameworkElementAutomationPeer.FromElement(child); if (item == null) { item = FrameworkElementAutomationPeer.CreatePeerForElement(child); } if (item != null) { list.Add(item); } } var emptyContentPresenter = ElementTreeHelper.EnumVisualDescendants(this.Owner, descendand => descendand is ContentPresenter) .Where(presenter => presenter.Equals(this.OwningChart.emptyContentPresenter)).SingleOrDefault() as ContentPresenter; if (emptyContentPresenter != null) { list.Add(FrameworkElementAutomationPeer.CreatePeerForElement(emptyContentPresenter)); } return(list); }
private void OnBusyIndicatorAnimationAdapterSizeChanged(object sender, SizeChangedEventArgs e) { if (this.Animation == null) { return; } if (this.Animation.Children.Count == 0) { return; } FrameworkElement owner = ElementTreeHelper.FindVisualAncestor <RadBusyIndicator>(this); if (owner == null) { return; } BusyIndicatorAnimation animation = ElementTreeHelper.FindVisualAncestor <BusyIndicatorAnimation>(this); if (animation == null) { return; } Point animationLocation = ElementTreeHelper.SafeTransformPoint(animation, owner, new Point(-10, 0)); this.AdaptAnimation(this.Animation, owner.RenderSize.Width + 10, animationLocation.X); }
/// <summary> /// Occurs when a System.Windows.FrameworkElement has been constructed and added to the object tree. /// </summary> protected override void OnLoaded() { base.OnLoaded(); if (this.itemAddedAnimationCache != null) { this.itemAddedAnimationCache.Ended -= this.OnItemAddedAnimation_Ended; this.itemAddedAnimationCache.Ended += this.OnItemAddedAnimation_Ended; } if (this.itemRemovedAnimationCache != null) { this.itemRemovedAnimationCache.Ended -= this.OnItemRemovedAnimation_Ended; this.itemRemovedAnimationCache.Ended += this.OnItemRemovedAnimation_Ended; } this.UpdateStrategyDefinitionPropertyChangedHandling(true); this.virtualizationStrategyDefinition.SynchStrategyProperties(this.virtualizationStrategy); if (this.scrollContentPresenter == null) { this.scrollContentPresenter = ElementTreeHelper.FindVisualDescendant <ScrollContentPresenter>(this.manipulationContainer); } this.BalanceVisualSpace(); }
internal override void TryFocusCell(DataGridCellInfo cellInfo, FocusState state) { base.TryFocusCell(cellInfo, state); if (cellInfo.Cell == null) { return; } var element = cellInfo.Cell.Container as FrameworkElement; if (element != null) { var control = element as Control; if (control != null) { control.Focus(state); } else { var firstControl = ElementTreeHelper.FindVisualDescendant <Control>(element); if (firstControl != null) { firstControl.Focus(state); } } } }
private void HighlightTextBlocks() { this.PrepareHighlightedRunsList(); IEnumerable <DependencyObject> textBlockDescendands = ElementTreeHelper.EnumVisualDescendants(this, descendand => descendand is TextBlock); foreach (TextBlock textBlock in textBlockDescendands) { if (!RadAutoCompleteBox.GetIsTextMatchHighlightEnabled(textBlock)) { continue; } if (this.owner.owner.FilterMode == AutoCompleteBoxFilterMode.StartsWith) { this.HighlightStartingMatch(textBlock, this.stringToHighlight, RadAutoCompleteBox.GetTextMatchHighlightStyle(textBlock)); } else { this.HighlightAllMatches(textBlock, this.stringToHighlight, RadAutoCompleteBox.GetTextMatchHighlightStyle(textBlock)); } } if (this.IsSelected) { this.ResetRunHighlightedForegroundValue(); } }
/// <inheritdoc /> protected override string GetNameCore() { var nameCore = base.GetNameCore(); var dateTimePickerParent = ElementTreeHelper.FindVisualAncestor <DateTimePicker>(this.DateTimePickerButton); if (dateTimePickerParent != null) { var dateTimePickerPeer = FrameworkElementAutomationPeer.FromElement(dateTimePickerParent) as DateTimePickerAutomationPeer; if (dateTimePickerPeer != null) { var datePickerHeader = dateTimePickerPeer.GetName(); if (!string.IsNullOrEmpty(datePickerHeader) && dateTimePickerParent.Header != null) { return(string.Format("{0} {1}", datePickerHeader, nameCore)); } } } if (!string.IsNullOrEmpty(nameCore)) { return(nameCore); } return(string.Empty); }
/// <summary> /// Called in the measure layout pass to determine the desired size. /// </summary> /// <param name="availableSize">The available size that was given by the layout system.</param> /// <returns>Returns the desired size of the indicator.</returns> protected override Size MeasureOverride(Size availableSize) { if (this.MeasureCallback != null) { this.MeasureCallback(); } if (this.ownerPanel == null) { this.ownerPanel = ElementTreeHelper.FindVisualAncestor <GaugePanel>(this); } Size result = RadGauge.NormalizeSize(availableSize); if (result.Width == 0 || result.Height == 0) { result = this.ownerPanel.LastMeasureSize; } this.Update(result); this.LastMeasureSize = result; return(result); }
private void ListBoxEx_Loaded(object sender, RoutedEventArgs e) { itemsPanel = ElementTreeHelper.FindVisualChildren <FullscreenTilePanel>(this).FirstOrDefault(); if (itemsPanel != null) { itemsPanel.InternalChildrenGenerated += ItemsPanel_InternalChildrenGenerated; } }
private void OnToggleSwitchEditorLoaded(object sender, RoutedEventArgs e) { this.switchKnobRect = ElementTreeHelper.FindVisualDescendant <Rectangle>(this.EditorControl, a => a.GetType() == typeof(Rectangle) && ((Rectangle)a).Name == SwitchKnobBoundsPartName); this.switchKnobOffEllipse = ElementTreeHelper.FindVisualDescendant <Ellipse>(this.EditorControl, a => a.GetType() == typeof(Ellipse) && ((Ellipse)a).Name == SwitchKnobOffPartName); this.outerBorderRect = ElementTreeHelper.FindVisualDescendant <Rectangle>(this.EditorControl, a => a.GetType() == typeof(Rectangle) && ((Rectangle)a).Name == OuterBorderPartName); this.UpdateSwitchBrushes(); this.EditorControl.Loaded -= this.OnToggleSwitchEditorLoaded; }
private void TopAppBar_Loaded(object sender, RoutedEventArgs e) { this.SetBinding(TrackerProperty, new Binding() { Path = new PropertyPath("BottomAppBar") }); this.DataContext = ElementTreeHelper.FindVisualAncestor <Page>(this); }
public void AddButtonClick(object sender, RoutedEventArgs e) { var ownerPage = ElementTreeHelper.FindVisualAncestor <Page>(this); if (ownerPage != null) { ownerPage.Frame.Navigate(typeof(FindCityPage)); } }
/// <inheritdoc /> protected override AutomationPeer OnCreateAutomationPeer() { RadCalendar calendar = ElementTreeHelper.FindVisualAncestor <RadCalendar>(this); if (calendar != null) { return(new CalendarViewHostAutomationPeer(this, calendar)); } return(null); }
/// <inheritdoc /> protected override AutomationPeer OnCreateAutomationPeer() { RadNumericBox parent = ElementTreeHelper.FindVisualAncestor <RadNumericBox>(this); if (parent != null) { return(new NumericTextBoxAutomationPeer(this, parent)); } return(base.OnCreateAutomationPeer()); }
private void OnLoaded(object sender, RoutedEventArgs e) { this.closeButton = ElementTreeHelper.FindVisualDescendant <Button>(this); this.closeButton.Click += this.OnCloseButtonClick; this.closeButtonAnimation = new OpacityAnimation(this.closeButton) { Duration = new Duration(TimeSpan.FromMilliseconds(200)) }; this.initialDelayTimer.Start(); }
protected override AutomationPeer OnCreateAutomationPeer() { var parent = ElementTreeHelper.FindVisualAncestor <RadRadialMenu>(this); if (parent != null) { return(new RadialMenuItemControlAutomationPeer(this, parent)); } return(base.OnCreateAutomationPeer()); }
private void FilterSettings_FilterChanged(object sender, FilterChangedEventArgs e) { if (mainModel.AppSettings.ViewSettings.GamesViewType != viewType) { return; } var scrollViewer = ElementTreeHelper.FindVisualChildren <ScrollViewer>(ListGames).FirstOrDefault(); scrollViewer?.ScrollToTop(); }
private void OnNativeSideDrawerLoaded(object sender, Windows.UI.Xaml.RoutedEventArgs e) { RadSideDrawer nativeSideDrawer = (RadSideDrawer)sender; Border swipeBorder = ElementTreeHelper.FindVisualDescendant <Border>(nativeSideDrawer); if (swipeBorder != null) { swipeBorder.IsHitTestVisible = false; } nativeSideDrawer.Loaded -= this.OnNativeSideDrawerLoaded; }
internal virtual bool IsCheckModeArea(RadDataBoundListBoxItem item, UIElement container, Point hitPoint) { if (!ElementTreeHelper.IsElementRendered(item) || !ElementTreeHelper.IsElementRendered(container as FrameworkElement)) { return(false); } Point relativeOffset = container.TransformToVisual(item).TransformPoint(new Point(0, 0)); hitPoint = new Point(relativeOffset.X + hitPoint.X, relativeOffset.Y + hitPoint.Y); return(item.IsPointInCheckModeAreaForItem(hitPoint)); }
private void radSlideView_SelectionChanged(object sender, SelectionChangedEventArgs e) { RadSlideView slideView = sender as RadSlideView; if (slideView != null) { var scrollViewer = ElementTreeHelper.FindVisualDescendant <ScrollViewer>(slideView.SelectedItemContainer); if (scrollViewer != null) { scrollViewer.ScrollToVerticalOffset(0); } } }
internal virtual bool ShouldToggleExpandOnTap(Windows.UI.Xaml.Input.TappedRoutedEventArgs e) { if (ElementTreeHelper.IsElementRendered(this.expanderHeaderLayoutRoot)) { Point position = e.GetPosition(this.expanderHeaderLayoutRoot); var rect = new Rect(new Point(), this.expanderHeaderLayoutRoot.RenderSize); return(rect.Contains(position)); } return(false); }
private void Initialize() { if (this.Owner == null) { RadRating parent = ElementTreeHelper.FindVisualAncestor <RadRating>(this); if (parent == null) { throw new InvalidOperationException(InvalidOwnerException); } this.Owner = parent; } }
void ProcessGotFocus(RoutedEventArgs e) { if (base.SelectedIndex < 0) { base.SelectedIndex = 0; } ListBoxItem targetElement = base.ContainerFromItem(base.SelectedItem) as ListBoxItem; if ((targetElement != null) && !ElementTreeHelper.IsKeyboardFocusWithin(targetElement)) { targetElement.Focus(FocusState.Programmatic); } }
public bool CanExecute(object parameter) { if (parameter == null) { return(false); } RadDataBoundListBoxItem item = ElementTreeHelper.FindVisualAncestor <RadDataBoundListBoxItem>(parameter as DependencyObject); //return item != null && item.Content is Verse; return(item != null); }
private void ViewSettings_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (mainModel.AppSettings.ViewSettings.GamesViewType != viewType) { return; } if (e.PropertyName == nameof(ViewSettings.GroupingOrder)) { ListGames.ItemsPanel = GetItemsPanelTemplateCache(); var scrollViewer = ElementTreeHelper.FindVisualChildren <ScrollViewer>(ListGames).FirstOrDefault(); scrollViewer?.ScrollToTop(); } }
private void TryFocus(FocusState state) { if (!this.IsTabStop) { return; } var focusedElement = FocusManager.GetFocusedElement() as DependencyObject; if (focusedElement == null || ElementTreeHelper.FindVisualAncestor <CalendarViewHost>(focusedElement) == null) { this.Focus(state); } }
private static void Control_Loaded(object sender, RoutedEventArgs e) { var elem = (FrameworkElement)sender; elem.Loaded -= Control_Loaded; foreach (var child in ElementTreeHelper.FindVisualChildren <FrameworkElement>(elem)) { if (child.Focusable) { child.Focus(); return; } } }
private void OnSlideViewLoaded(object sender, RoutedEventArgs e) { // Start always with the information visible SlideViewAndFilmStrip.ShowOverlayContent(); // Start the timer. If the user does not do anything in a few seconds then remove the overlay //_overlayTimer = new Timer(HideOverlayAndAppbar, null, new TimeSpan(0,0,10), new TimeSpan(0,0,0,0,-1)); SetMoveButtons(); // Bind to item state changed event to explicit release the image when scrolling in filmstrip mode. var zoomableListBox = ElementTreeHelper.FindVisualDescendant <ZoomableListBox>(sender as RadSlideView); zoomableListBox.ItemStateChanged += ZoomableListBoxOnItemStateChanged; }
public override DataTemplate SelectTemplate(object item, DependencyObject container) { RadSlideView view = ElementTreeHelper.FindVisualAncestor <RadSlideView>(container); if (view == null) { return(null); } if ((item as Concept).HasSound) { return(this.DefaultTemplate); } return(NoSoundTemplate); }