/// <summary> /// Initializes a new instance of the AccordionItem class. /// </summary> public AccordionItem() { // initialize to no action. ScheduledAction = AccordionAction.None; DefaultStyleKey = typeof(AccordionItem); _interaction = new InteractionHelper(this); }
/// <summary> /// Schedules the specified action. /// </summary> /// <param name="action">The action to be performed.</param> private void Schedule(AccordionAction action) { this.ScheduledAction = action; if (this.ParentAccordion == null) { // no parentaccordion to notify, so just execute. this.StartAction(); } else { bool directExecute = this.ParentAccordion.ScheduleAction(this, action); if (directExecute) { this.StartAction(); } } }
/// <summary> /// Schedules the specified action. /// </summary> /// <param name="action">The action to be performed.</param> private void Schedule(AccordionAction action) { #if SILVERLIGHT if (DesignerProperties.GetIsInDesignMode(this) && ExpandSite != null) { switch (action) { case AccordionAction.None: break; case AccordionAction.Collapse: ExpandSite.Percentage = 0; break; case AccordionAction.Expand: case AccordionAction.Resize: ExpandSite.Percentage = 1; break; default: throw new ArgumentOutOfRangeException("action"); } return; } #endif ScheduledAction = action; if (ParentAccordion == null) { // no parentaccordion to notify, so just execute. StartAction(); } else { bool directExecute = ParentAccordion.ScheduleAction(this, action); if (directExecute) { StartAction(); } } }
/// <summary> /// Schedules the specified action. /// </summary> /// <param name="action">The action to be performed.</param> private async void Schedule(AccordionAction action) { if (Windows.ApplicationModel.DesignMode.DesignModeEnabled && ExpandSite != null) { switch (action) { case AccordionAction.None: break; case AccordionAction.Collapse: ExpandSite.Percentage = 0; break; case AccordionAction.Expand: case AccordionAction.Resize: ExpandSite.Percentage = 1; break; default: throw new ArgumentOutOfRangeException("action"); } return; } ScheduledAction = action; if (ParentAccordion == null) { // no parentaccordion to notify, so just execute. StartAction(); } else { bool directExecute = await ParentAccordion.ScheduleAction(this, action); if (directExecute) { StartAction(); } } }
/// <summary> /// Schedules the specified action. /// </summary> /// <param name="action">The action to be performed.</param> private void Schedule(AccordionAction action) { if (DesignerProperties.GetIsInDesignMode(this) && ExpandSite != null) { switch (action) { case AccordionAction.None: break; case AccordionAction.Collapse: ExpandSite.Percentage = 0; break; case AccordionAction.Expand: case AccordionAction.Resize: ExpandSite.Percentage = 1; break; default: throw new ArgumentOutOfRangeException("action"); } return; } ScheduledAction = action; if (ParentAccordion == null) { // no parentaccordion to notify, so just execute. StartAction(); } else { bool directExecute = ParentAccordion.ScheduleAction(this, action); if (directExecute) { StartAction(); } } }
/// <summary> /// Allows an AccordionItem to signal the need for a visual action /// (resize, collapse, expand). /// </summary> /// <param name="item">The AccordionItem that signals for a schedule.</param> /// <param name="action">The action it is scheduling for.</param> /// <returns>True if the item is allowed to proceed without scheduling, /// false if the item needs to wait for a signal to execute the action.</returns> internal virtual bool ScheduleAction(AccordionItem item, AccordionAction action) { if (SelectionSequence == SelectionSequence.CollapseBeforeExpand) { lock (this) { if (!_scheduledActions.Contains(item)) { _scheduledActions.Add(item); } } if (_currentActioningItem == null) { Dispatcher.BeginInvoke(new Action(StartNextAction)); } return false; } else { return true; } }
/// <summary> /// Allows an AccordionItem to signal the need for a visual action /// (resize, collapse, expand). /// </summary> /// <param name="item">The AccordionItem that signals for a schedule.</param> /// <param name="action">The action it is scheduling for.</param> /// <returns>True if the item is allowed to proceed without scheduling, /// false if the item needs to wait for a signal to execute the action.</returns> internal async virtual Task<bool> ScheduleAction(AccordionItem item, AccordionAction action) { if (SelectionSequence == SelectionSequence.CollapseBeforeExpand) { lock (this) { if (!_scheduledActions.Contains(item)) { _scheduledActions.Add(item); } } if (_currentActioningItem == null) { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, StartNextAction); } return false; } else { return true; } }