I’m working on a tutorial to build a media player in Silverlight and am trying to wire up an EventHandler to the timer.Tick event of a DispatchTimer object so that the time of the video is synced with a Slider object.
The sample code is in C# and I can’t for the life of me figure out the proper syntax in VB.NET with RaiseEvent and/or Handles to wire up the event. Below is the relevant C# code. I’ll include comments on where I’m getting stuck.
private DispatchTimer timer;
public Page()
{
//...
timer = new DispatchTimer();
timer.Interval = TimeSpan.FromMilliseconds(50);
timer.Tick += new EventHandler(timer_Tick); // <== I get stuck here b/c
// I can't do "timer.Tick += ..." in VB.NET
}
void timer_Tick(object sender, EventArgs e)
{
if (VideoElement.NaturalDuration.TimeSpan.TotalSeconds > 0)
{
sliderScrubber.Value = VideoElement.Position.TotalSeconds /
VideoElement.NaturalDuration.TimeSpan.TotalSeconds;
}
}
Similar:
- How does "Custom Event" work in VB.Net? In C# if I want to create a “Custom Event” you do something like this: private EventHandler _MyEvent; Public Event EventHandler MyEvent { add{ _MyEvent...
- Handling VB.NET events in VB6 code I have some VB6 code that instantiates a class which handles events that are being raised from a VB.NET component. The VB6 is pretty straightforward:...
- Override Events in VB.NET Hello I would like to shadow/override an event in VB.NET. I do it only because I have to implement in this object an interface, that...
- VB Equivalent of C# Event Creation I’m trying to extend the GridView class to always show the header and footer even when the datasource is empty by using the code I...
- How to hook up an event to an event in VB.Net Is it possible to hook up an event to another event in VB8? I have this code in C#… public event ShowAboutDialog = delegate {};...