0

I am working On a App where a Grid/Popup Opens on a Listbox Tap , Grid Opens Successfully using IValueConverter but my problem is :

-> When I press back key on phone I hook up an RelayCommand on "Home_ViewModel.cs" , I was able to successfully called method but Grid Doesn't hide on BackKeyPress.

-> I called Base Class IsVisible property on BackKeyPress Command but didn't get to work correctly.

-> I don't know where I am working wrong either on OOPs concept or Binding Data on XAML. Kindly Look at My Code having Sky-Drive Link. Help Me In This !!!

Sky-Drive code link :

Problematic Code Link

--> same qut. i Asked HERE but didn't get any response .

Regards,

Pardeep

Pardeep Sharma
  • 407
  • 1
  • 5
  • 20
  • Hi Devs, After 2-3 hours of Headache I got to know that My ViewModels are not Connect/Communicate with each other : -> I would like to Connect/communicate Home_ViewModel.cs with AllPost_ViewModel.cs to hide My Grid Layout on BackKeyPress ("Grid" that opened on ListBox Tap) . -> As I am working with MVVM first time so I don't Know How to Use GalaSoft.MvvmLight.Messaging.Messenger to connect my ViewModel. -> Help !! Regards, Pardeep – Pardeep Sharma Oct 24 '13 at 11:29

2 Answers2

0

Here are some samples: one, two.

In worth case, you can call from one VM to another via:

    ServiceLocator.Current.GetInstance<OtherVM>().Update();

A bit better way is

    ServiceLocator.Current.GetInstance<OtherVM>().MyCommand.Execute();

Use it only for fast testing, real project should work on Messages.

Community
  • 1
  • 1
Vitalii Vasylenko
  • 4,776
  • 5
  • 40
  • 64
0

Hi Vitalii Vasylenko I am disagree with your solution , so what I'd so far :

Register a Messenger on Allpost_ViewModel constr. like :

public AllPost_ViewModel()
    {
        GalaSoft.MvvmLight.Messaging.Messenger.Default.Register<string>(this, "String", executeThisFunction);
    }

and Pass a message from Home_ViewModel (on backkeypress) like :

public void ExecuteBackCommand(System.ComponentModel.CancelEventArgs e)
    {
        if (App.Visible)
        {                
            GalaSoft.MvvmLight.Messaging.Messenger.Default.Send<string>("Dummy text message", "String");
        }

    }

-> It successfully display a message via Message passing, But I didn't how to use this technique to accomplish my respective task.
->I just want to hide my popup on backkeypress.. Help !!
-> updated link of my code is here : Code Link

Regards, Pardeep

Pardeep Sharma
  • 407
  • 1
  • 5
  • 20