In WPF Prism, you can call a method on the Main Window from a partial view.

By using Prism's Event Aggregator, you can avoid direct references between view models and easily handle events raised within the application.

The following is an example of using the Event Aggregator to call a method on the Main Window's ViewModel from a partial view.

### 1. Create the method you want to call on the Main Window's ViewModel.

```cs
public class MainWindowViewModel : BindableBase
{
    private readonly IEventAggregator _eventAggregator;

    public MainWindowViewModel(IEventAggregator eventAggregator)
    {
        _eventAggregator = eventAggregator;
    }

    public void SomeMethod()
    {
        // Do something
    }
}
```

### 2. Inject the Event Aggregator into the partial view.

```cs
public class PartialView : UserControl
{
    private readonly IEventAggregator _eventAggregator;

    public PartialView(IEventAggregator eventAggregator)
    {
        _eventAggregator = eventAggregator;
    }
}
```

### 3. Use the Event Aggregator in the partial view to publish an event.

For example, you can publish an event named `"SomeEvent"` as follows.

```cs
_eventAggregator.GetEvent<SomeEvent>().Publish();
```

As it stands, this results in an error because the `SomeEvent` class does not exist.
So create a new class named `SomeEvent` that inherits from `PubSubEvent`.
```cs
public class SomeEvent : PubSubEvent
{
}
```

As a side note, if you want to prepare an event that takes a parameter, define it on `PubSubEvent`'s generic type.
```cs
public class SomeEvent : PubSubEvent<string>
{
}
```

### 4. Create a method on the Main Window's ViewModel that subscribes to `"SomeEvent"`.

This way, the corresponding method is called whenever the event is published.

```cs
public class MainWindowViewModel : BindableBase
{
    private readonly IEventAggregator _eventAggregator;

    public MainWindowViewModel(IEventAggregator eventAggregator)
    {
        _eventAggregator = eventAggregator;
        _eventAggregator.GetEvent<SomeEvent>().Subscribe(OnSomeEvent);
    }

    public void OnSomeEvent()
    {
        SomeMethod();
    }

    public void SomeMethod()
    {
        // Do something
    }
}
```

With this, you can call a method on the Main Window's ViewModel from a partial view.  
By publishing an event inside the partial view, you can create a method on the Main Window's ViewModel that receives the event and performs the necessary processing.
