/// <summary> /// 增加media组件 /// </summary> /// <param name="layout"></param> /// <param name="SourcePath"></param> /// <param name="Region"></param> public static UIElement AddMediaComponent(this Canvas layout, string SourcePath, ProgramRegion Region, bool Visible = true) { MediaControl mediaControl = new MediaControl(); mediaControl.mediaUri = new Uri(SourcePath); Canvas.SetLeft(mediaControl, Region.x); Canvas.SetTop(mediaControl, Region.y); mediaControl.Width = Region.w; mediaControl.Height = Region.h; mediaControl.Visibility = Visible == true ? Visibility.Visible : Visibility.Hidden; layout.Children.Add(mediaControl); mediaControl.LoadMedia(); return(mediaControl); }