コード例 #1
0
        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]);
        }
コード例 #2
0
        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]);
        }