Register  Login
Blog
Silverlight Desktop Blog
Jul 19

Written by: Michael Washington
7/19/2008 3:48 PM

After finishing the sample code for the Silverlight drag and drop import and export we realized that SilverlightDesktop would present some unique challenges.

After working with this for a few hours we came up with a solution where you simply make a method such as this in the module:

public void AddDelegates(SilverlightDragAndDrop.Page objParentPage)
{
ParentPage = objParentPage;
// Add delegates to the parent to allow it to handle the drag and drop
FrameworkElement objFrameworkElement1 = (FrameworkElement)this.DragElement1;
objFrameworkElement1.MouseLeftButtonDown +=
new MouseButtonEventHandler(ParentPage.objFrameworkElement_MouseLeftButtonDown);
FrameworkElement objFrameworkElement2 = (FrameworkElement)this.DragElement2;
objFrameworkElement2.MouseLeftButtonDown +=
new MouseButtonEventHandler(ParentPage.objFrameworkElement_MouseLeftButtonDown);
FrameworkElement objFrameworkElement3 = (FrameworkElement)this.DragElement3;
objFrameworkElement3.MouseLeftButtonDown +=
new MouseButtonEventHandler(ParentPage.objFrameworkElement_MouseLeftButtonDown);
}

and then dynamically invoke it in the parent after the module's control has been instantiated with code like this:

objUserControl.GetType().InvokeMember("AddDelegates",
BindingFlags.InvokeMethod, null, objUserControl, parameters);

This adds yet more Reflection to the model but it works. Reflection is "expensive" resource-wise but it's in the .Net API for a reason. The good thing is that it still presents no breaking changes.

The simplicity of the "Hello World" module is important for the adoption of the SilverlightDesktop framework among developers. If they can't make a Hello World module easily they will find a different framework.

Now they can implement import and export with only a few steps.

We posted the proof of concept here. There is no need to write it up because the code will show up in SilverlightDesktop in about a month.

Tags:
  

Terms Of Use | Privacy Statement | Copyright 2008 by SilverlightDesktop.net Dynnamite DotNetNuke Skins & Modules