In Silverlight a tooltip can have as many elements in it as you want.
However, it doesn't receive focus so you can't have user interactivity in it.
Could you, though, start a video playing as soon as the tooltip opens and have the video stop as soon as the tooltip closes?
-
This is my first answer on Stack Overflow so I ask for your good humor.
I think you could run your video in the tooltip by using a video brush.Here's some code I used to paint a fire video on the bar in the chart that represented heating with corn. ( long story) right here, you can see it is set to the fill of an ellipse.
#region video brush setup protected void setupVideo() { VideoBrush _vb; MediaElement mevideo; _vb = new VideoBrush(); mevideo = new MediaElement(); mevideo.SetValue(Grid.NameProperty, "video"); Uri videoUri = new Uri("http://www.faxt.com/videos/ezburnboilerfire.wmv", UriKind.Absolute); mevideo.Source = videoUri; mevideo.Visibility = Visibility.Collapsed; mevideo.MediaEnded += new RoutedEventHandler(me_MediaEnded); MediaRoot.Children.Add(mevideo); _vb.SetSource(mevideo); Ellipse el = new Ellipse(); el.Width = 100; el.Height = 100; el.Fill = _vb; MediaRoot.Children.Add(el); }
-
You could do it with a VideoBrush as suggested by BPerreault, but you could also just set Tooltip.Content to a MediaElement.
That is because the Content property of Tooltip inherits from ContentControl and the Content property of a ContentControl can be any type of object, such as a string, a UIElement, or a DateTime. When Content is set to a UIElement (like MediaElement), the UIElement is displayed in the ContentControl. When Content is set to another type of object, a string representation of the object is displayed in the ContentControl. (from documentation)
It should be something like this:
<TextBlock x:Name="myText" Text="MouseOver and you'll get a ToolTip!"> <ToolTipService.ToolTip> <MediaElement x:Name="myVideo" Source="Butterfly.wmv" Width="300" Height="300" /> </ToolTipService.ToolTip> </TextBlock >
0 comments:
Post a Comment