Duplicate items in ActiveViews

Docking/MDI for WPF Forum

Posted 13 years ago by ting xue
Version: 11.1.0541
Platform: .NET 4.0
Environment: Windows XP (32-bit)
Avatar
To test how to control the docking and mdi components in prism pattern, I made some modification on the Prism Integration Unity Sample source code, and found something interesting but not as expected. So I describe it below.

1. Enviroment
a) .Net Framework 4.0
b) vs 2010
c) actipro 2011.1 (build 0541)
d) prism 4
e) Win XP

2. Modifications
a) MainModule.cs

          ......
            //mainRegion.Add(richTextDocumentItemViewModel);
            //mainRegion.Add(textDocumentItemViewModel);    
            mainRegion.Add(richTextDocumentItemViewModel, "view1");    //So that the viewmodel could be referenced 
        mainRegion.Add(textDocumentItemViewModel, "view2");
    
b) Shell.xaml.cs

  public partial class Shell : Window
  {  
      private IRegionManager regionManager;
      
      public Shell(IRegionManager regionManager)
        {
            InitializeComponent();

#if PRISM2
            this.Title = "Actipro Prism v2.2 (Unity) Integration Sample";
#else
            this.Title = "Actipro Prism v4.0 (Unity) Integration Sample";
#endif

            this.regionManager = regionManager;
        }
        
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            IRegion region = regionManager.Regions["MainRegion"];
            foreach (var view in region.ActiveViews)
            {
                textBox1.Text += view.ToString() + Environment.NewLine;
            }
        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            IRegion region = regionManager.Regions["MainRegion"];
            var view = region.GetView("view1");
            region.Activate(view);
        }

        private void button3_Click(object sender, RoutedEventArgs e)
        {
            IRegion region = regionManager.Regions["MainRegion"];
            var view = region.GetView("view2");
            region.Activate(view);
        }
      }
    }
    
c)add three buttons(button1, button2, button3) and textBox1 to the shell.xaml

OK, that's all.

Now let's begin to test:

step 1. compile and run PrismIntegration.v40.Unity.exe. All the components are loaded successfully. The WelcomeDocument.rtf dock window seems to be actived.

step 2. click button1, which should append the current activeview to textBox1. But, nothing happens, as if none of the dock windows is active.

step 3. click the tab, just the tab, of WelcomeDocument.rtf dock window.

step 4. click button1 again. "ActiproSoftware.Windows.PrismIntegration.ViewModels.RichTextDocumentItemViewModel" is appended to the textBox1.

As I thought, since WelcomeDocument.rtf dock window is in the front, it should be "isActive". Am I wrong?

Let's continue. Restart the application.

Step 5. Click button3. ReadOnlyDocument is activated.

Step 6. Click button2. WelcomeDocument is activated.

Step 7. Click button3. ReadOnlyDocument is activated.

Step 8. Click button2. Attention. Nothing happens. WelcomeDocument is not activated as expected.

Step 9. Click button1. Tow lines are appended to textBox1:
ActiproSoftware.Windows.PrismIntegration.ViewModels.TextDocumentItemViewModel
ActiproSoftware.Windows.PrismIntegration.ViewModels.TextDocumentItemViewModel

Even after I active it manually and then swith to ReadOnlyDocument, WelcomeDocument can not be activacated any more. It seems like a bug in ActiveViews generation. I trace the code but have no idea about the reason. Hope you could fix it.

Thank all your team.

Comments (2)

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

The issue you describe in Step 4 is by design. There can be several selected views, but only active view. The Welcome DocumentWindow is selected in the MDI area, but the Solution Explorder ToolWindow is also selected. Both of these windows can be the active window, which effectively means it has the keyboard focus. So at any given time you can have numerous "selected" windows.

When the sample starts up, the focus is not moved to any of the windows so there is no active window (i.e. DockSite.ActiveWindow is null). You could manually move the keyboard focus to the Welcome DocumentWindow in order to make it active, or call the DocumentWindow.Activate(true) method.

For you other issue, there was a bug in our code that I have corrected for the next maintenance release.


Actipro Software Support

Posted 13 years ago by ting xue
Avatar
That's great.

I am really appreciate your good job.

BTW, where and when can I find the new patch?

[Modified at 05/11/2011 12:33 AM]
The latest build of this product (v24.1.2) was released 2 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.