Setting the active window from code behind

Docking/MDI for WPF Forum

Posted 5 years ago by Doug Beck
Version: 18.1.0675
Avatar

I have an application which uses docking to show a variety of windows, which by default show up as tabbed. When a user chooses a window from the main menu, I'd like the corresponding window to show up as active. However, when I manually set up this window's model to IsActive, the previously selected window's model remains IsActive as well. OK, fine, just set that model's IsActive to false but even after IsActive = false is set I still see the value as true. 

What should I do? Is there a better way to set a window to be active?

Comments (3)

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Doug,

It seems like you are setting the model's IsActive property here.  Are you sure you set up a two-way binding on IsActive?  I would expect that setting IsActive = true on one model would update the property on the other model as well if so.  Our MVVM Document Windows QuickStart shows examples of setting IsActive = true, and all the other models are updating properly.

If that doesn't help, can you give us steps to reproduce it in our MVVM Document Windows QuickStart?


Actipro Software Support

Posted 5 years ago by Damir Bulic
Avatar

I just stumbled upon a very similar issue. My application keeps documents on the server and re-initializes them on application startup. Even though I set up IsActive to true, it's ignored and the rightmost document is activated. This breaks our workspace restore functionality.

So, I fired up your MVVM Documents demo, activated the second document and still the last one is activated. Not sure why the order of documents is reversed, as well. Version is 18.1.0675. Screenshot: https://www.dropbox.com/s/jyvqh69kfb480br/MVVM-activation.png.

/////////////

public MainViewModel() {
this.CreateNewTextDocument(false);
this.CreateNewTextDocument(true);
this.CreateNewImageDocument(false);
}

/////////////

viewModel.Title = $"{viewModel.FileName} {activate}"; // in CreateTextDocument, line 114 of MvvmDocumentWindows.MainViewModel.cs

Answer - Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Damir,

Thanks for providing the repro steps.  We found the problem for that example and corrected it for the next build.  Please write our support address if you'd like to test a preview build with the update.


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.