private static void OnStateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { StateImage stateImage = (StateImage)d; int index = (int)e.NewValue; if (stateImage.Images == null || stateImage.Images.Count <= index || index < 0) { return; } stateImage.Background = new ImageBrush(stateImage.Images[index]); }
private static void OnImagesChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { StateImage stateImage = (StateImage)d; List <ImageSource> imageSourceList = (List <ImageSource>)e.NewValue; if (imageSourceList.Count <= stateImage.State || stateImage.State < 0) { return; } stateImage.Background = new ImageBrush(imageSourceList[stateImage.State]); }