/// <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; }
//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; }
/// <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); } }