Posted 14 years ago
by ting xue
Version: 11.1.0541
Platform: .NET 4.0
Environment: Windows XP (32-bit)

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.csb) Shell.xaml.cs
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.
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");
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);
}
}
}
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.