I hope you can help me with my problem.
What is the situation:
I'm working on a C# WPF application with the MVVM patte. I'm using Calibu.Micro and MahApps.Metro.
I have a list of ViewModels in ViewModelA:
ObservableCollection<ViewModelB> ViewModelList { get; set; } // short version
There is a ListView in my corresponding View that binds to this list:
<ListView ItemsSource="{Binding ViewModelList}">
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<ContentControl cal:View.Model="{Binding }" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
The ViewModels in the list are displayed by a ContentControl.
In ViewModelB there is an event that gets called on a double click on the corresponding View (MetroWindow):
public void OnDoubleClick()
{
var windowManager = IoC.Get<IWindowManager>();
windowManager.ShowWindow(new ViewModelC());
}
The WindowManager shows a new non modal window for me (View of ViewModelC).
What is the problem:
The non modal window is not focused and behind my main window after it's shown by WindowManager.
I tried a lot of settings for my window like ShowActivated, Owner, Topmost... When I set the owner to my main window then the shown window behaves like Topmost is set to true.
I just want the window to appear on front of my main window (not Topmost=true) and focused.
Unsatisfying solution:
I can replace the ContentControl with the View I want to display and get rid of the list of ViewModels. If I do that I can listen to the MouseDoubleClick event of my ListView and get the selected element with the property SelectedIndex.
If I do it that way the shown window behaves like I want it to (on top, focused).
But ViewModelB needs a lot of logic and I want to encapsulate it.
It would be really great if someone can solve my problem.
Best regards, mash
