InteractiveViewModel and MVVM

Topics: Windows Phone 8
Jun 26, 2015 at 2:51 PM
Edited Jun 26, 2015 at 2:53 PM
Hi,

I'm trying to implement custom UI buttons for my needs (WP8.1 app). So I've created a class that inherits InteractiveViewModel.
public class VideoPlayerInteractiveViewModel : InteractiveViewModel
    {
        public VideoPlayerInteractiveViewModel(MediaPlayer player)
            :base(player)
        {
            Debug.WriteLine("VideoPlayerInteractiveViewModel constructor");            
        }
    }
I'm trying hard to use MVVM approach in my App so I'm Binding VideoPlayerInteractiveViewModel to the property
InteractiveViewModel="{Binding VideoView}".
Binding going well but since I need to pass the MediaPlayer object I'm creating a new one:
_player = new MediaPlayer();
VideoView = new VideoPlayerInteractiveViewModel(_player);
And sure I loose control over the Xaml defined player... I can't interact with UI controls.

Is there some way to get things work with MVVM? Or am I doing something wrong?

Thank you.
Coordinator
Jul 7, 2015 at 5:33 PM
Set the x:Name property in the XAML and then in the code behind you'll be able to reference the XAML defined player by name rather than creating a new one.
Jul 7, 2015 at 9:32 PM
MVVM means no code behind.

Отправлено с моего Windows Phone

От: [email removed]
Отправлено: ‎07.‎07.‎2015 19:34
Кому: [email removed]
Тема: Re: InteractiveViewModel and MVVM [playerframework:640508]

From: ibennett

Set the x:Name property in the XAML and then in the code behind you'll be able to reference the XAML defined player by name rather than creating a new one.