private static void OnEventNameChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { RadContextMenu menu = d as RadContextMenu; menu.RemoveHandler(e.OldValue as string); menu.AttachHandler(); }
private static void OnEventTriggered(object sender, EventArgs e) { FrameworkElement fe = sender as FrameworkElement; if (fe != null) { RadContextMenu menu = GetContextMenu(fe); if (menu != null) { // this.mousePosition is not updated correctly when using the Left mouse button, // so we eventually get it from the event args. MouseButtonEventArgs buttonArgs = e as MouseButtonEventArgs; if (buttonArgs != null) { // Handle MouseButtonEventArgs otherwise they will bubble up and can open another context menu. if (menu.ModifierKeyPressed) { buttonArgs.Handled = true; } menu.mousePosition = buttonArgs.GetPosition(null); } menu.TriggerEventFired(); } } }
private static void OnContextMenuChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { FrameworkElement element = d as FrameworkElement; RadContextMenu oldMenu = e.OldValue as RadContextMenu; RadContextMenu newMenu = e.NewValue as RadContextMenu; ////if (DesignerProperties.GetIsInDesignMode(d)) ////{ //// return; ////} if (element == null) { throw new ArgumentNullException("d"); } if (oldMenu != null) { oldMenu.ClearReferences(); } if (newMenu != null) { newMenu.CreateReferences(element); } }
private static void OnAttachOnHandledEventsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { RadContextMenu menu = d as RadContextMenu; FrameworkElement element = menu.elementWithContextMenu; menu.RemoveHandler(menu.EventName); menu.AttachHandler(); }
private static void OnIsOpenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { ////if (DesignerProperties.GetIsInDesignMode(d)) ////{ //// return; ////} RadContextMenu menu = (RadContextMenu)d; if ((bool)e.NewValue) { if (menu.rootPopup == null) { menu.HookupRootPopup(); } } else { menu.CurrentSelection = null; menu.RemoveKeyDownHandler(); menu.CloseAll(); } }
/// <summary> /// Initializes a new instance of the RadContextMenuAutomationPeer class. /// Automation Peer for the RadContextMenu class. /// </summary> /// <param name="owner">The object that is associated with this AutomationPeer.</param> public RadContextMenuAutomationPeer(RadContextMenu owner) : base(owner) { }
private void RoutedEventFired(object sender, RoutedEventArgs e) { RadContextMenu.OnEventTriggered(sender, e); }
private void OnElementWithContextMenuMouseClick(object sender, MouseButtonEventArgs e) { RadContextMenu.OnEventTriggered(sender, e); }
/// <summary> /// When overridden in a derived class, undoes the effects of the <see cref="M:System.Windows.Controls.ItemsControl.PrepareContainerForItemOverride(System.Windows.DependencyObject,System.Object)"/> method. /// </summary> /// <param name="element">The container element.</param> /// <param name="item">The Item.</param> protected override void ClearContainerForItemOverride(DependencyObject element, object item) { base.ClearContainerForItemOverride(element, item); RadContextMenu.SetInsideContextMenu(this, false); }
/// <summary> /// Prepares the specified element to display the specified item. /// </summary> /// <param name="element">Element used to display the specified item.</param> /// <param name="item">Specified item.</param> protected override void PrepareContainerForItemOverride(DependencyObject element, object item) { base.PrepareContainerForItemOverride(element, item); RadContextMenu.SetInsideContextMenu(element, true); }
/// <summary> /// Sets the value of the ContextMenu property of the specified element. /// </summary> public static void SetContextMenu(FrameworkElement element, RadContextMenu value) { element.SetValue(ContextMenuProperty, value); }
/// <summary> /// When overridden in a derived class, is invoked whenever application code or internal processes (such as a rebuilding layout pass) call <see cref="M:System.Windows.Controls.Control.ApplyTemplate"/>. /// </summary> public override void OnApplyTemplate() { base.OnApplyTemplate(); RadContextMenu menu = this.GetChildByName("PART_categoryMenu") as RadContextMenu; if (menu != null) { menu.ItemClick += this.MenuItemClick; menu.ClickToOpen = true; } RadComboBox timeMarker = this.GetChildByName("PART_TimeMarkers") as RadComboBox; if (timeMarker != null) { timeMarker.ClearSelectionButtonContent = LocalizationManager.GetString("Clear"); } RadScheduler scheduler = Scheduler as RadScheduler; if (scheduler != null && !String.IsNullOrEmpty(scheduler.GroupBy) && this.RecurrenceMode == RecurrenceMode.Occurrence) { this.ResourceTypesVisibility = Visibility.Collapsed; } var appointment = this.EditedAppointment as AppointmentBase; if (appointment != null) { if (appointment.TimeMarker != null) { this.TimeMarker = this.TimeMarkers.SingleOrDefault(tm => tm.TimeMarkerName == appointment.TimeMarker.TimeMarkerName); } if (appointment.Category != null) { this.Category = appointment.Category; } } if (scheduler != null) { if (this.Categories == null) { if (scheduler.Categories != null && scheduler.Categories.Count > 0) { this.Categories = scheduler.Categories; } else { this.Categories = Telerik.Windows.Controls.Scheduler.Categories.AllCategories; } } this.ResourceTypeModels = new ResourceTypeViewModelCollection(); foreach (var resourceType in scheduler.ResourceTypes) { this.ResourceTypeModels.Add(new ResourceTypeViewModel(resourceType, this.EditedAppointment)); } } this.ConfigureDateTimePickers(); this.ConfigureButtons(); }