コード例 #1
0
        /// <summary>
        /// Will be called whenenver something makes a change to the "Description" property.
        /// </summary>
        /// <param name="d"></param>
        /// <param name="e"></param>
        private static void OnDescriptionPropertyChange(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            GenericPaletteItem p = (GenericPaletteItem)d;

            //set the palette object's description to the updated text
            p.PaletteDescription.Text = p.Description;
        }
コード例 #2
0
        //where we put event listeners
        #region event listeneres

        /// <summary>
        /// Will be called whenever someone makes a change to the "IconSource" property
        /// </summary>
        /// <param name="d"></param>
        /// <param name="e"></param>
        private static void OnIconSourcePropertyChange(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            GenericPaletteItem p = (GenericPaletteItem)d;

            //create a new bitmap image, assign it to the GenericPaletteItem's image source
            //property
            BitmapImage bi = new BitmapImage();

            bi.UriSource         = new Uri(e.NewValue.ToString(), UriKind.Relative);
            p.PaletteIcon.Source = bi;
        }
コード例 #3
0
        /// <summary>
        /// Will be called whenenver something makes a change to the "Selected" property.
        /// </summary>
        /// <param name="d"></param>
        /// <param name="e"></param>
        private static void OnSelectedPropertyChange(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            GenericPaletteItem item = (GenericPaletteItem)d;

            bool value = (bool)e.NewValue;

            //if value is true, then the current item has been selected
            if (value)
            {
                item.LayoutRoot.Background = new SolidColorBrush(SelectedColor);
            }
            else
            {
                item.LayoutRoot.Background = new SolidColorBrush(UnSelectedColor);
            }
        }