2012-04-03 97 views

回答

0

你可以用負MarginsClipToBounds組放置在一個ContentPresentertrue,這將作物的視頻。

0

它可以通過設置MediaElement的Clip屬性來完成。你可以將它設置爲任何PathGeometry,下面是一個簡單的例子。

XAML:

<Window x:Class="Window1" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Title="Window1" Height="378" Width="472"> 
    <Canvas> 
     <MediaElement LoadedBehavior="Play" Name="myME" Source="c:\\1.wmv" Width="320" Height="240" Canvas.Left="0" Canvas.Top="0"> 
     </MediaElement>  
    </Canvas> 
</Window> 

C#

using System; 
using System.Text; 
using System.Windows; 
using System.Windows.Controls; 
using System.Windows.Input; 
using System.Windows.Media; 
using System.Windows.Media.Imaging; 
using System.Windows.Shapes; 

namespace tests 
{ 
    /// <summary> 
    /// Interaction logic for Window1.xaml 
    /// </summary> 
    public partial class Window1 : Window 
    { 
     public Window1() 
     { 
      InitializeComponent(); 
      this.MyMedia1.Clip = 
       new RectangleGeometry(new Rect(0, 0, myME.Width/3, myME.Height)); 
     } 
    } 
}