Brandmuscle
Top achievements
Rank 1
Brandmuscle
asked on 02 Aug 2009, 05:26 AM
I need to handle the MouseDown events on the Next/Prev buttons for the RadMediaPlayer. How can I go about doing this?
I need to handle the MouseDown event for next, and while the mouse is down "DoWork()". Same with previous.
Any help would be much appriciated.
Thanks
I need to handle the MouseDown event for next, and while the mouse is down "DoWork()". Same with previous.
Any help would be much appriciated.
Thanks
4 Answers, 1 is accepted
0
Hi Dan,
The easiest way to achieve what you are looking for, is to use the VisualTreeHelper class to retrieve the first visual element in RadMediaPlayer's ControlTemplate. After that you can use the FindName() method to get the buttons you are looking for. For better explanation please refer to the code bellow;
If you have additional questions, let us know.
Best wishes,
Kiril Stanoev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
The easiest way to achieve what you are looking for, is to use the VisualTreeHelper class to retrieve the first visual element in RadMediaPlayer's ControlTemplate. After that you can use the FindName() method to get the buttons you are looking for. For better explanation please refer to the code bellow;
public MainPage() |
{ |
InitializeComponent(); |
Loaded += new RoutedEventHandler(MainPage_Loaded); |
} |
void MainPage_Loaded(object sender, RoutedEventArgs e) |
{ |
Dispatcher.BeginInvoke(() => |
{ |
// Get the first visual element in RadMediaPlayer's ControlTemplate |
FrameworkElement layoutRoot = VisualTreeHelper.GetChild(RadMediaPlayer1, 0) as FrameworkElement; |
// The buttons responsible for navigating among the chapters are called NextChapterButton and PreviousChapterButton |
Button nextChapterButton = layoutRoot.FindName("NextChapterButton") as Button; |
Button previousChapterButton = layoutRoot.FindName("PreviousChapterButton") as Button; |
// Silverlight 3 supports listening for already handled events. |
nextChapterButton.AddHandler(FrameworkElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(ChapterButton_MouseLeftButtonDown), true); |
previousChapterButton.AddHandler(FrameworkElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(ChapterButton_MouseLeftButtonDown), true); |
}); |
} |
private void ChapterButton_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
{ |
// DoWork(); |
} |
If you have additional questions, let us know.
Best wishes,
Kiril Stanoev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Brandmuscle
Top achievements
Rank 1
answered on 04 Aug 2009, 02:22 PM
Now the only problem is getting the buttons to not be disabled. Is there any easy way to make them enabled at all times?
0
Brandmuscle
Top achievements
Rank 1
answered on 04 Aug 2009, 07:04 PM
found a work around for now. enabling them after they get disabled. not a perfect work around though. any ideas would be helpful though.
0
Hi Dan,
Unfortunately the only way to enable the buttons is only after they get disabled. What you can do in this case is to make nextChapterButton and previousChapterButton member variables, and in MediaOpened event handler of RadMediaPlayer to make then enabled.
For our next version of RadMediaPlayer we will make sure this gets fixed.
Let us know if you experience any additional questions.
Regards,
Kiril Stanoev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Unfortunately the only way to enable the buttons is only after they get disabled. What you can do in this case is to make nextChapterButton and previousChapterButton member variables, and in MediaOpened event handler of RadMediaPlayer to make then enabled.
Button nextChapterButton; |
Button previousChapterButton; |
public MainPage() |
{ |
InitializeComponent(); |
Loaded += new RoutedEventHandler(MainPage_Loaded); |
RadMediaPlayer1.MediaOpened += new EventHandler<Telerik.Windows.RadRoutedEventArgs>(RadMediaPlayer1_MediaOpened); |
} |
void RadMediaPlayer1_MediaOpened(object sender, Telerik.Windows.RadRoutedEventArgs e) |
{ |
nextChapterButton.IsEnabled = true; |
previousChapterButton.IsEnabled = true; |
} |
For our next version of RadMediaPlayer we will make sure this gets fixed.
Let us know if you experience any additional questions.
Regards,
Kiril Stanoev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.