ColorAnimation 으로,
Storyboard.SetTargetProperty 의 PropertyPath 속성으로
Brush 관련 프로퍼티 후에 SolidColorBrush.ColorProperty
예 ) Rectangle 컨트롤의 Fill 속성 변경 시
Storyboard.SetTargetProperty(colorAnimation, new PropertyPath("(0).(1)",
new DependencyProperty[]
{
Shape.FillProperty,
SolidColorBrush.ColorProperty
}));
[ 실행화면 ]
[ 소스 코드 ] { tabItem.BeginStoryboard(CreateStoryboard(Colors.Blue, Border.BorderBrushProperty)); rectangle.BeginStoryboard(CreateStoryboard(Colors.LightSeaGreen, Shape.FillProperty)); rectangle.BeginStoryboard(CreateStoryboard(Colors.Green, Shape.StrokeProperty)); border.BeginStoryboard(CreateStoryboard(Colors.Red, Border.BorderBrushProperty)); } Storyboard CreateStoryboard(Color color, DependencyProperty property) { ColorAnimation colorAnimation = Storyboard.SetTargetProperty(colorAnimation, new PropertyPath("(0).(1)", new DependencyProperty[] { property, SolidColorBrush.ColorProperty })); Storyboard storyBoard = new Storyboard() { AutoReverse = true, RepeatBehavior = RepeatBehavior.Forever, }; storyBoard.Children.Add(colorAnimation); return storyBoard; }
void MainWindow_Loaded(object sender, RoutedEventArgs e)
new ColorAnimation(color, new Duration(TimeSpan.FromSeconds(2)));
'Window > WPF' 카테고리의 다른 글
데이터 바인딩 ( Data Binding ) (0) | 2012.07.24 |
---|---|
WPF Media Player ( Design. GomPlayer ) (0) | 2012.03.12 |
Storyboard.SetTargetProperty에 RenderTransformProperty 설정하기 (0) | 2011.03.04 |
ListBox ItemsPanel 변경하기 (0) | 2011.03.04 |
Image Rotate (4) | 2010.11.04 |