SDMS - Using the Logger (TraceTool) to aid development

Our SDMS main view takes advantage of routed events - we'll subscribe all button clicks to the UserControl_Click event handler. 

<UserControl x:Class="MainView"

   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

   x:Name="MainViewUC"

   ButtonBase.Click="UserControl_Click"> 

 

    <DockPanel>

        <Menu DockPanel.Dock="Top">

            <MenuItem Header="File"/>

            <MenuItem Header="Tools"/>

            <MenuItem Header="Help"/>

        </Menu>

Since all routed events will be processed by a single method in our presenter we can use the Factory Pattern to process them.  For extensibility purposes we won't assume that the routed event will always be a button click. 

Typically you might place a break point on line 43 to determine what properties can be used to create the factory - we'll let the Logger (TraceTool) assist us here:

In our demo we clicked the "Toolbox" vertical button.

Below we see that we can use the e.RoutedEvent property to determine which class should be resolved to handle event processing, in this case "ButtonBase.Click".   The e.OriginalSource can be used to determine what Command should be executed within the resolved class.  

Click HERE for flash demo 
http://www.codeplex.com/SDMS | Source Code Tab | Change Set: 23138

Click HERE for flash demo

 


Tags: , , ,
Categories: CompositeWPF


Actions: E-mail | Permalink |  Grammar/Typo/Better way? Please let me know