Exemple #1
0
        /// <summary>
        /// This is called when the template has been bound to the control
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            ElementViewer        = (ItemViewer)GetTemplateChild(ElementViewerName);
            ElementSelectedColor = (ColorItem)GetTemplateChild(ElementSelectedColorName);
            ElementAdd           = (Button)GetTemplateChild(ElementAddName);
            ElementCustom        = (StackPanel)GetTemplateChild(ElementCustomName);

            ElementViewer.ItemSelected += new ItemViewerEventHandler(ElementViewer_ItemSelected);
            ElementAdd.Click           += new RoutedEventHandler(ElementAdd_Click);

            foreach (ColorItem item in _pending)
            {
                ElementViewer.Add(item);
            }
            Set(Custom.ToArray(), true);
            _pending.Clear();

            _dropDown = (DropDown)ElementRoot;

            _dropDown.OpenPosition = OpenPosition;
            _dropDown.LostFocus   += new RoutedEventHandler(ColorSelector_LostFocus);

            SetSelected(_selected);
        }
Exemple #2
0
 private void AddColor(ColorItem item)
 {
     if (ElementViewer != null)
     {
         ElementViewer.Add(item);
     }
     else
     {
         _pending.Add(item);
     }
 }