/// <summary>
        /// Pick a color
        /// </summary>
        /// <param name="sender">the button</param>
        /// <param name="setColor">the function to set the color</param>
        private void PickColor(object sender, Action <Microsoft.PlayerFramework.CaptionSettings.Model.Color> setColor)
        {
            var frameworkElement = sender as FrameworkElement;

            var buttonRect = frameworkElement.GetElementRect();

            var colorPicker = new ColorPickerControl();

            var flyout = new Popup
            {
                Child            = colorPicker,
                HorizontalOffset = buttonRect.Right - colorPicker.Width,
                VerticalOffset   = buttonRect.Bottom < Window.Current.Bounds.Height / 2 ? buttonRect.Bottom : buttonRect.Top - colorPicker.Height,
            };

            flyout.IsLightDismissEnabled = true;

            flyout.IsOpen = true;

            colorPicker.ColorSelected += new EventHandler <ColorEventArgs>(delegate(object sender2, ColorEventArgs colorSelected)
            {
                flyout.IsOpen = false;

                setColor(colorSelected.Color);
            });
        }
        /// <summary>
        /// Pick a color
        /// </summary>
        /// <param name="sender">the button</param>
        /// <param name="setColor">the function to set the color</param>
        private void PickColor(object sender, Action<Microsoft.PlayerFramework.CaptionSettings.Model.Color> setColor)
        {
            var frameworkElement = sender as FrameworkElement;

            var buttonRect = frameworkElement.GetElementRect();

            var colorPicker = new ColorPickerControl();

            var flyout = new Popup
            {
                Child = colorPicker,
                HorizontalOffset = buttonRect.Right - colorPicker.Width,
                VerticalOffset = buttonRect.Bottom < Window.Current.Bounds.Height / 2 ? buttonRect.Bottom : buttonRect.Top - colorPicker.Height,
            };

            flyout.IsLightDismissEnabled = true;

            flyout.IsOpen = true;

            colorPicker.ColorSelected += new EventHandler<ColorEventArgs>(delegate(object sender2, ColorEventArgs colorSelected)
            {
                flyout.IsOpen = false;

                setColor(colorSelected.Color);
            });
        }
        /// <summary>
        /// Apply templates
        /// </summary>
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            this.FontColorType = this.GetTemplateChild("FontColorType") as ComboBox;
            this.BackgroundColorType = this.GetTemplateChild("BackgroundColorType") as ComboBox;
            this.WindowColorType = this.GetTemplateChild("WindowColorType") as ComboBox;
            this.CaptionFontStyle = this.GetTemplateChild("CaptionFontStyle") as ComboBox;
            this.FontColorButton = this.GetTemplateChild("FontColorButton") as Button;
            this.BackgroundColorButton = this.GetTemplateChild("BackgroundColorButton") as Button;
            this.WindowColorButton = this.GetTemplateChild("WindowColorButton") as Button;

            this.FontColorPicker = this.GetColorPicker("FontColorPicker", this.OnFontColorSelected);
            this.BackgroundColorPicker = this.GetColorPicker("BackgroundColorPicker", this.OnBackgroundColorSelected);
            this.WindowColorPicker = this.GetColorPicker("WindowColorPicker", this.OnWindowColorSelected);            

            this.Preview = this.GetTemplateChild("Preview") as PreviewControl;

            this.Initialize();
        }