//Color picked event handler
        void ColorPicked(object sender, Windows.UI.Color color)
        {
            //Get the source InkColor instance
            InkColor pressed = sender as InkColor;

            //Check if the instance is valid
            if (pressed != null)
            {
                //Iterate over all of the pickers InkColors and update their border color to highlight the active one
                foreach (InkColor inkcolor in m_colors)
                {
                    if (inkcolor == pressed)
                    {
                        inkcolor.BorderColor = this.MainBorder.BorderBrush;
                    }
                    else
                    {
                        inkcolor.BorderColor = m_inActiveBrush;
                    }
                }
            }
            //Raise the InkColorPicked event
            if (InkColorPicked != null)
            {
                InkColorPicked(this, color);
            }
        }
 /// <summary>
 /// A helper method used to add a InkColor instance to the UI
 /// </summary>
 /// <param name="picker"></param>
 private void AddPicker(InkColor picker)
 {
     //Add a color picked event handler
     picker.ColorPicked += ColorPicked;
     //Add the InkColor instance to the InkColor list
     m_colors.Add(picker);
     //Add the InkColor instance to the UI stack
     this.PickerStack.Children.Add(picker);
 }
        /// <summary>
        /// A helper method used to create a new InkColor instance using the provided color
        /// </summary>
        /// <param name="color">The ink's color</param>
        /// <returns></returns>
        private InkColor ProcudePicker(Windows.UI.Color color)
        {
            //Create a new InkColor instance
            InkColor picker = new InkColor();

            //Set the object's color
            picker.Color = color;
            //Set the object's boder to the inactive color
            picker.BorderColor = m_inActiveBrush;
            //Set the object's border Size
            picker.BorderSize = new Thickness(3.5);
            //Set the pickers Width to 105
            picker.Width = 105.0;
            //Return the new InkColor instance
            return(picker);
        }
        /// <summary>
        /// A helper method used to produce the pickers colors
        /// </summary>
        private void ProcudeColors()
        {
            //Set the inactive boder color to Transparent
            m_inActiveBrush = new SolidColorBrush(Windows.UI.Colors.Transparent);

            //Create a new InkColor list
            m_colors = new List <InkColor>();

            //Create the first active color using the ProducePicker helper
            InkColor active = ProcudePicker(Windows.UI.Colors.Black);

            //Set the active InkColor object's border color to the mian border's color
            active.BorderColor = this.MainBorder.BorderBrush;
            //Add the active InkColor to the picker list
            AddPicker(active);
            //Add some more InkColors using the ProducePicker and AddPicker helpers
            AddPicker(ProcudePicker(Windows.UI.Colors.Red));
            AddPicker(ProcudePicker(Windows.UI.Colors.Yellow));
            AddPicker(ProcudePicker(Windows.UI.Colors.Orange));
            AddPicker(ProcudePicker(Windows.UI.Colors.Green));
            AddPicker(ProcudePicker(Windows.UI.Colors.Blue));
        }