private void RadialController_RotationChanged(RadialController sender,
                                               RadialControllerRotationChangedEventArgs args)
 {
     RadioButton[] inkingTools   = { FillCellButton, PenButton, PencilButton, EraserButton };
     Action[]      inkingActions =
     {
         OnFillCellButtonClicked,
         OnPenButtonClicked,
         OnPencilButtonClicked,
         OnEraserButtonClicked
     };
     if (CurrentRadialSelection == ColoringBookRadialController.InkingTool)
     {
         SelectedToolIndex = (4 + SelectedToolIndex +
                              (args.RotationDeltaInDegrees > 0 ? 1 : -1)) % 4;
         inkingActions[SelectedToolIndex]();
         inkingTools[SelectedToolIndex].IsChecked = true;
         inkingTools[SelectedToolIndex].Focus(FocusState.Keyboard);
     }
     else if (CurrentRadialSelection == ColoringBookRadialController.StrokeSize)
     {
         if (SelectedToolIndex == 1 || SelectedToolIndex == 2)
         {
             var flyout = FlyoutBase.GetAttachedFlyout(inkingTools[SelectedToolIndex]);
             flyout.ShowAt(inkingTools[SelectedToolIndex] as FrameworkElement);
             Slider slider = (SelectedToolIndex == 1) ?
                             PenStrokeWidthSlider : PencilStrokeWidthSlider;
             slider.Focus(FocusState.Keyboard);
             int val    = (int)args.RotationDeltaInDegrees;
             int newVal = ((int)slider.Value) + (val > 0 ? 1 : -1);
             newVal       = (newVal > 24) ? 24 : newVal;
             newVal       = (newVal < 0) ? 0 : newVal;
             slider.Value = newVal;
         }
     }
     else if (CurrentRadialSelection == ColoringBookRadialController.StrokeSizeDialClick)
     {
         Slider slider = (SelectedToolIndex == 1) ? PenStrokeWidthSlider : PencilStrokeWidthSlider;
         slider.Focus(FocusState.Keyboard);
         int val    = (int)args.RotationDeltaInDegrees;
         int newVal = ((int)slider.Value) + (val > 0 ? 1 : -1);
         newVal       = (newVal > 24) ? 24 : newVal;
         newVal       = (newVal < 0) ? 0 : newVal;
         slider.Value = newVal;
     }
     else if (CurrentRadialSelection == ColoringBookRadialController.EraserTool)
     {
         if ((args.RotationDeltaInDegrees > 0) && (DrawingTool == DrawingTool.Eraser))
         {
             EraserFlyoutList.SelectedIndex = 1;
             CellEraseListItem.Focus(FocusState.Keyboard);
         }
         else if ((args.RotationDeltaInDegrees < 0) && (DrawingTool == DrawingTool.EraseCell))
         {
             EraserFlyoutList.SelectedIndex = 0;
             StrokeEraseListItem.Focus(FocusState.Keyboard);
         }
     }
 }
        private void DialInvokedEraserFlyout_Opened(object sender, object e)
        {
            // Now set focus on selected erasing tool.
            if (DrawingTool == DrawingTool.Eraser)
            {
                StrokeEraseListItem.Focus(FocusState.Keyboard);
            }
            else
            {
                CellEraseListItem.Focus(FocusState.Keyboard);
            }

            (sender as FlyoutBase).Opened -= DialInvokedEraserFlyout_Opened;
        }