Replacing WindowDictionary.xaml

Mar 10, 2010 at 4:26 PM

I have tried copying the WindowDictionary.xaml to my shell project and making a simple change (eg the icon).  When I run the program the icon shows correctly although within 2 seconds the computer goes into an endless loop and hangs to the point that a reboot is required.  Even if I make no changes to the ResourceDictionary this happens.  I have also tried removing the original from the merged dictionaries during load and the same happens.

I do see some kind of exception occur in the composite framework but by then the computer has hung and I can't get details of the exception.

I've obviously missed the point when restyling the shell.   Could someone please help?

Developer
Mar 10, 2010 at 5:33 PM

Hi M1dst,

Here are some instructions on how to implement a custom style.

Get the latest source version, right click on the installer project and install it to your default location.

Open Visual Studio, and create a new calcium project.

Open the App.xaml file and then paste into the Application.Resources element the shall view style and the BooleanToVisibilityConverter from the WindowsDictionary.xaml file.

I was unable to reproduce your issue using this method. Let me know how you go.

Katka

Mar 10, 2010 at 7:47 PM

Hi Katka,

Good evening to you and Daniel.  Thanks for your suggestion.  It was very similar to what I had tried so I tried a few things.

First I tried your suggestion of putting the styles directly into my app.xaml file.  Fail.

I then tried a new shell project and it worked.

I tried going back to my original shell and removing my many modules.  Fail.  So I then knew it was the shell.  A quick 2 minute review of the two shells revealed the differences.  My app.xaml + cs was not the same as the current version.  I guess over time it got changed and mine was generated from the original template build.  It was only a tiny difference but enough to completely break!

For others reading the only additional thing you will need to add at the top of your app.xaml is the namespace references (with assembly)

xmlns:Calcium="clr-namespace:DanielVaughan.Calcium;assembly=DanielVaughan.Calcium.Client"
xmlns:cal="clr-namespace:Microsoft.Practices.Composite.Presentation.Regions;assembly=Microsoft.Practices.Composite.Presentation"
xmlns:Controls="clr-namespace:DanielVaughan.Calcium.Gui.Controls;assembly=DanielVaughan.Calcium.Client"
xmlns:Gui="clr-namespace:DanielVaughan.Calcium.Gui;assembly=DanielVaughan.Calcium.Client"

So the app is working perfectly again.  Now I shall style the app to look how I wish.

Fantastic work from you both

James

Developer
Mar 10, 2010 at 10:14 PM

Hi James,

Thanks for letting me know that all is well.

Look forward to hearing your feedback about using Calcium.

Katka

 

 

Mar 11, 2010 at 1:51 PM

It appears that not very much can be modified just by changing the style due to code running against specific regions.  So if changing from a TabControl to a StackPanel the app wont run.

Am I right in thinking that to completely replace the shell I need to override:

AppStarter, BootStrapper, ShellView, RegionNames etc.

This is going to be a much bigger task than I thought as I wish to change the layout and number of regions available.

Has anyone got any pointers or samples I could look at?

Coordinator
Mar 11, 2010 at 6:30 PM

Hi James,

You don't need to do all of that. Just replace the shell in the IOC container.

What I will do, however, is change the ShellView so that it won't fail if particular parts are not present. That will make things easier, and, on reflection, makes more sense.

To replace the shell entirely though, be sure to register the shell, the main window and a command service as shown in the following example.

void Application_Startup(object sender, StartupEventArgs e)
{
...
var container = new UnityContainer();
ServiceLocatorSingleton.Instance.InitializeServiceLocator(container);
var customShellView = new CustomShellView();
/* Retrieve viewmodel from view and register it. */
var shell = (IShell)shellView.ViewModel;
Container.RegisterInstance(shell);
Container.RegisterInstance(customShellView);
Container.RegisterInstance((ICommandService)shellView);			
var appStarter = new AppStarter();
appStarter.Start();
}

 

Cheers,

Daniel

Coordinator
Mar 12, 2010 at 12:02 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Mar 12, 2010 at 2:43 PM

Hi Daniel,

Thanks for the tip above.  I spent a few minutes playing but couldn't get things working properly.  I think I really need to spend some time learning more. as it's all still very new to me.  I find the current shell has so many things to it that it is a little overwhelming.  I'll keep plodding on.

James

Mar 22, 2010 at 8:21 PM
Edited Mar 22, 2010 at 10:57 PM

Could you give me complete example for Customization of shell view and other modules view

 

thanks

Abdul