Show Video Preview in Control ToolTip in WPF

No.of Views1697
Bookmarked0 times
Downloads 
Votes0
By  kirtan007   On  16 May 2010 03:05:19
Tag : WPF , Applications
Article teach about how to show video preview inside the controls tool tip
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at info@codegain.com

 

Introduction

In this article I will show you how you can show movie clip when popping up tool tip.You can use this when create Explorer kind of UI and want to preview movies inside it or media player which shows movie preview when mouse hover is there.

Technology

 .net framework 4.0 WPF

Implementation:

First of all let me show you what we are trying to build as sample. 

Image Loading

Let's start with creating a new C# WPF Application By going to
 
File >>New project>>Visual C# >>Windows>>WPF Application


we want to display tool tip of the button control when user mouse hover the button the movie preview should be displayed as shown in the picture WPF allow us to nesting the controls that is advantage.Drag drop 1 button control from the tool box set its properties like below

<Button Content="Movie Preview" Height="23" HorizontalAlignment="Left" Margin="27,12,0,0" Name="button1" VerticalAlignment="Top" Width="101" >
</Button>

now we want to show tool tip for that we need to Set button's ToolTip property like below by mentioning the <Button.ToolTip> tag inside the Button Tag so our modified button code will look like below .

<Button Content="Movie Preview" Height="23" HorizontalAlignment="Left" Margin="27,12,0,0" Name="button1" VerticalAlignment="Top" Width="101" Click="button1_Click" >
 <Button.ToolTip>
 
</Button.ToolTip>
</Button>

Now take one stack panel and inside it we have defined one border element that will provide border to our Media Element in which we are going to show the preview video. So modified final code of the button will look like

<Button Content="Movie Preview" Height="23" HorizontalAlignment="Left" Margin="27,12,0,0" Name="button1" VerticalAlignment="Top" Width="101" >
            <Button.ToolTip>
                <StackPanel>
                <Border Height="250" Width="250" Background="Transparent" BorderBrush="OrangeRed" BorderThickness="5,5,10,10" CornerRadius="10,100,10,100" >
                   <MediaElement Source="C:\Users\Kirtan\Pictures\2010-05-15 25rtan\25rtan 005.MOV" Volume="0" Margin="10"/>
                   </Border>
                </StackPanel>
            </Button.ToolTip>
        </Button>

Here we have used two element Border and the Media element media element is used to show movie so we have to set its properties like source defines what movie it will show volume defines sound volume ..we have defined MediaElement inside the border element so that border will be shown outside of the media element as shown in screen shot ..

We have achieved the leaf like of shape by setting border Corner radius property :)

That's it what the project and it does what I have told.

Note:

In sample project attached I have not provided the movie because of very huge size of movie. Use any movie path in source property of the mediaelement from your computer to run the project correctly.
Thank you.

Sample Project Source

Download Source Files-50 kb

 
Sign Up to vote for this article
 
About Author
 
kirtan007
Occupation-
Company-
Member Type-Senior
Location-Not Provided
Joined date-02 Jul 2009
Home Page-http://kirtan.uni.cc
Blog Page-
He completed his Bachelor of Computer Application from Gujarat University 2009 .He is doing Master of Computer Application from Gujarat Technological University right now .. His area of Interests are Web Hacking , C# .net Windows form ,asp.net , WPF ,Silverlight ,SQL Server and Some PHP.
 
 
Other popularSectionarticles
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top