Using WECPOF in runtime

This article was moved to MDriven Wiki Using WECPOF in runtime

You can use WECPOF in design time ECO projects and in files.

This article explains how to use it in runtime to deliver finished applications.

It starts out as an ordinary ECO project (create one from the wizard, Create new project Eco project).

You then create your model, update the code, configure your Persistence mapper of choice, set up any remote persistence mapper and synchronization if you want to just as the PDF-tutorials explain, Create or evolve your database, or derive the model from an existing database with the Reverse derive options.

Then add a WPF-Window or a WPF-Page (for browser applications).

Make sure your project references WECPOFLogic, then add a reference to the xaml :


And add a MainMenu and a WECPOFWindowEnvironment (this is where the WECPOF windows will be hosted)

Code Snippet
  1. <Window x:Class=“WpfApplication1.Window1”
  2.     xmlns=“”
  3.     xmlns:x=“”
  4.         xmlns:toolkit=“”
  5.     xmlns:wecpof=“clr-namespace:WECPOFLogic;assembly=WECPOFLogic”
  6.     Title=“Window1” Height=“314” Width=“354”>
  7.     <Window.Resources>
  8.         <LinearGradientBrush x:Key=“WECPOFWinBackgroundBrush” EndPoint=“0,1” StartPoint=“0,0”>
  9.             <GradientStop Color=“#CCC” Offset=“0.0” />
  10.             <GradientStop Color=“#EEE” Offset=“1.0” />
  11.         </LinearGradientBrush>
  12. … cut for clarity…
  13.     </Window.Resources>
  14.     <Grid>
  15.         <Grid.RowDefinitions>
  16.             <RowDefinition Height=“22”></RowDefinition>
  17.             <RowDefinition></RowDefinition>
  18.         </Grid.RowDefinitions>
  19.         <Menu Grid.Row=“0”  Name=“MainMenu”>
  20.         </Menu>
  21.         <wecpof:WECPOFWindowEnvironment x:Name=“WecpofWinEnv”>
  22.         </wecpof:WECPOFWindowEnvironment>
  23.     </Grid>
  24. </Window>

In code behind we need to create our ecospace and hook everything up; this is boiler plate code:

Code Snippet
  1. public partial class Window1 : Window
  2. {
  3.   EcoSpace _ecospace;
  4.   MenuHandling _MenuHandling;
  5.   public Window1()
  6.   {
  7.     InitializeComponent();
  8.     // Create ecospace or use one that you have
  9.     _ecospace = new EcoProject1.EcoProject1EcoSpace();
  10.     _ecospace.Active = true;
  11.     // Start up the Eco UI dequeuer ; if not set nothing will show
  12.     WPFDequeuer.Active = true;
  13.     // Load viewmodel definitions from embedded resources
  14.     ViewModelDefinitionsInApplication.Init(_ecospace);
  15.     // Create a WECPOF menu handling component
  16.     _MenuHandling = new MenuHandling();
  17.     // Define where WECPOF should look for styles
  18.     WecpofWinEnv.PathToStyles = Directory.GetCurrentDirectory() + “\\Styles”;
  19.     // And to where WECPOF should apply a choosen style
  20.     WecpofWinEnv.ResourceDictionaryTargetForStyles(this);
  21.     // Tell the MenuHandling component where to put the MenuItems. Hand over the list of Actions from ECO, hand over the EcoSpace.
  22.     // Send in the WindowEnvironment defined in xaml, and say in what context should the speed keys be evaluated
  23.     _MenuHandling.InitMainMenu(MainMenu, ViewModelDefinitionsInApplication.GetActionsRuntime(), _ecospace, WecpofWinEnv, this);
  24.     // Let the WECPOF Window environment know about the MenuHandling component
  25.     WecpofWinEnv.InstallMenuHandling(_MenuHandling);
  26.     // Implement the event to implement Quit…
  27.     MenuHandling.OnExit += new EventHandler<EventArgs>(MenuHandling_OnExit);
  28.   }
  29.   void MenuHandling_OnExit(object sender, EventArgs e)
  30.   {
  31.     Close();
  32.   }
  33. }

And you are done:


This entry was posted in WCF, WECPOF, Xaml. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.