How to Handle NavigationEventArgs in MVVM Light

Mar 7, 2013 at 8:52 PM
Hi

I want to try to do the webBrowser1_Navigated in MVVM light instead of codebehind but what I am doing is not working.

I made a new project with the MVVM light template and added this
        public RelayCommand<NavigationEventArgs> MyCommand
        {
            get;
            private set;
        }

      public MainViewModel(IDataService dataService)
        {
           
            _dataService = dataService;
            _dataService.GetData(
                (item, error) =>
                {
                    if (error != null)
                    {
                        // Report error here
                        return;
                    }

                    WelcomeTitle = item.Title;
                });

            MyCommand = new RelayCommand<NavigationEventArgs>(e =>
                {
                    var d = e;
                    var a = d.Content;
                });
               
        }
thin in the xaml I have
           <phone:WebBrowser IsScriptEnabled="True"  Name="test214" HorizontalAlignment="Left" VerticalAlignment="Bottom" Height="617" Width="480">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Navigated">
                        <GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding MyCommand, Mode=OneWay}" PassEventArgsToCommand="True" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </phone:WebBrowser>
I tried to trigger a navigation too by doing this
  public MainPage()
        {
            InitializeComponent();
            test214.Navigate(new System.Uri("https://www.google.ca/"));
        }
my break point never get triggered that I have on these lines
      var d = e;
                    var a = d.Content;
Am I doing it wrong?