WPF使用Animation仿WeChat(微信)播放语音消息
效果图预览
新建MyCustomControl类。
public class MyCustomControl : Control
{
private static Storyboard MyStory;
private ObjectAnimationUsingKeyFrames MyAnimation;
private List< BitmapImage> ImageList;
private UIElement animation;
public static readonly DependencyProperty DurationProperty =
DependencyProperty. Register ( "Duration" , typeof ( TimeSpan) ,
typeof ( MyCustomControl) , new PropertyMetadata ( null ) ) ;
public TimeSpan Duration
{
get {
return ( TimeSpan) GetValue ( DurationProperty) ; }
set {
SetValue ( DurationProperty, value ) ; }
}
public static readonly DependencyProperty IsLitProperty =
DependencyProperty. Register ( "IsLit" , typeof ( bool ) ,
typeof ( MyCustomControl) , new PropertyMetadata ( false , new PropertyChangedCallback ( OnIsLitChanged) ) ) ;
public bool IsLit
{
get {
return ( bool ) GetValue ( IsLitProperty) ;