About Me

reno, NV, United States
As of 2011, I have ten years experience in various technologies as C#, WPF, Java, J2EE, C++. For the past three years, I have been extensively working on various .net and java technologies including but not limited to WPF , C# , WCF and composite application guidance (Prism ).

Monday, April 13, 2009

WPF UI Waiting for server animated with dependency control.








Writing a WPF application often requires communicating with Server. When the WPF application requires to contact with server, we would like to show a neat animation on the UI like Internet explorer.






This listing shows a way to create an userControl which can be used in applications like


.....
xmlns:WA="clr-namespace:WaitingAnimated" .... />

Margin="200, 50, 300, 300"/>


In the source code attached I have a toggle button which starts/stops the animation by setting the value of IsAnimated to true or false...


private void Button_Click(object sender, RoutedEventArgs e)
{

animatedIcon.IsAnimated = !animatedIcon.IsAnimated;
}


Going thru XAML in the user control which is not rocket science but still...

The Grid.Resources has a storyboard, the repeat behavior of animation is forever and the storyboard target property is Angle of the path.



BeginTime="00:00:00"
Storyboard.Target="{Binding ElementName=path}"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)"
RepeatBehavior="Forever">






Path is the union of two circles. The important things in path are the rendertransform origin which translates the origin to the corresponding value, i typically define rendertransform and add all children even if i dont use to keep code extensible. Path fill is the color in the circular path which is filled .

Data="........"
RenderTransformOrigin="0.5,0.5" x:Name="path">




















Source code here.

No comments:

Followers

Blogger Syntax Highliter