If you're using a MediaElement to play your video, just listen for the MouseEntered Event and call Play().
Note: The LoadedBehavior property of MediaElement must be set to Manual in order to be able to interactively stop, pause, and play the media.
Here's an example:
In C# code-behind:
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void mediaElement1_MouseEnter(object sender, MouseEventArgs e)
{
mediaElement1.Play();
}
private void mediaElement1_MouseLeave(object sender, MouseEventArgs e)
{
mediaElement1.Stop();
}
private void mediaElement1_Loaded(object sender, RoutedEventArgs e)
{
mediaElement1.Pause();
}
}
In XAML:
<Window x:Class="VideoTest.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<MediaElement Margin="12"
Name="mediaElement1"
Source="mediaFile.avi"
LoadedBehavior="Manual"
MouseEnter="mediaElement1_MouseEnter"
MouseLeave="mediaElement1_MouseLeave"
Loaded="mediaElement1_Loaded"
/>
</Grid>
</Window>