Silverlight, WCF RIA Services »

[27 Sep 2009 | 0 Comments]

As some of you might know, the company I work for is hosting a BESUG session on Silverlight & RIA Services shortly (October 15th / click here to register!), for which I am the speaker.  At the moment, I’m composing a few of the slides and writing up some code, and I was wondering: if you had the possibility to ask a question about RIA Services, what would it be?

 

I’m not talking about the more general things (like “how do I get to my data”), those things will be addressed.  I’m looking for more specific questions, like “how do you work around having to rewrite code when you regenerate your DomainService?“, or “what are good strategies to achieve X or Y?” Hoping for some input on this, I decided to quickly blog this. ;-)

 

 

So, in short: what would YOU like to know about RIA Services?  Let me know (mail, twitter, or by replying to this post).  Tnx!

 

Silverlight, Drag and Drop Manager »

[16 Sep 2009 | 0 Comments]

Quick update: I’ve registered my Silverlight Drag and Drop Manager for the Silverlight Control Builder Contest, and it’s been accepted!  :-)  Check out all the entries here.

 

Entry deadline is September 19th, so I suppose I’ll know soon enough how it compares to the other entries.  I, for one, am quite curious about what the judges have to say about it – no matter where it ends in the contest, it’ll probably get me some tips and advice on what can be improved for future releases. 

 

Of course, I’ll keep you all updated!

Silverlight, Drag and Drop Manager »

[10 Sep 2009 | 0 Comments]

A new version of my open source project, the Silverlight Drag and Drop Manager, has just been released on CodePlex.

 

This is a major release, including various bugfixes, performance enhancements and loads of new features, including the ability to customize the return & switch-animations with easing & duration, the ability to customize the DropBorderBrush, a DropMode-property defining what should happen when you drop a DragSource, an AllowAnyDropTarget-property (so you don't have to manually add a list of valid DropTargets for each DragSource), a DragHandleMode-property, and many more.

 

Version 2.0 comes in 2 flavours: binaries for SL2 and binaries for SL3, including an updated sample application in the SL3 version.  If possible, I'd advise you to use SL3 (it allows for easing animations with the Drag and Drop manager), but if you've still got a project in SL2 that's been using a previous release of this software, you can safely upgrade.

 

For an all new example application, all the details, downloads, … one stop!

image

A full list of changes can be found on that CodePlex site, but for reference, here’s the list:

On DragSource:

  • Added property: AllDropTargetsValid:
    When this is set to true, all droptargets on the page will be valid for this dragsource.  The droptarget-list-property will effectively be ignored when this is set to true (default: false)
  • Added property: AutoFitGhost:
    Determines wether or not to auto-fit the ghost control.  It this is true, the ghost (if available) will be resized to match the content (default: false)
  • Added property: DragHandleMode:
    This property determines how you can drag your dragsource around: by using a draghandle (a bar on top of your dragsource), or without one, meaning you can drag by clicking anywhere in the dragsource
  • Added property: DropMode:
    Determines the behaviour when a dragsource is dropped, and the drop is valid: by default, the dragsource is dropped on the droptarget.  If you set DropMode to "ReturnDragSource", the dragsource is returned to where it originated from.  This mode can be useful if you just want to execute some code on dropping (dragsourcedropped event on droptarget is triggered and can be handled if you add a handler to it), but you do not want the dragsource to be removed from the originating collection.
  • Added property: ReturnAnimationDuration:
    Determines the length of the animation shown when returning a DragSource to its original position (default: 0.2)
  • Added property: ReturnAnimationEasingFunction:
    Determines the easing function of the animation shown when returning a DragSource to its original position (default: none, Silverlight 3 (or higher) required)
  • Added property: SwitchAnimationDuration:
    Determines the length of the animation shown when switching 2 DragSources (default: 0.2)
  • Added property: SwitchAnimationEasingFunction:
    Determines the easing function of the animation shown when switching 2 DragSources (default: none, Silverlight 3 (or higher) required)
  • Changed property: GhostVisibility:
    Changed ShowGhost (bool) to GhostVisibility (Visibility).  Determines wether or not the ghost control should be shown (default: Visible)

On DropTarget:

  • Added property: AllowPositionSave
    Determines wether or not the position of a droptarget should be saved.  Setting this option to true results in a significant increase in performance: in regular mode (when this property is false), droptarget positioning is calculated on the fly while dragging a dragsource.  When this is set to true, it's only calculated when the droptarget is loaded.  Do keep in mind that setting this to true will result in strange behaviour if the droptarget hasn't got a fixed position on screen (eg: when the droptarget itself can be moved around).   However, you can recalculate this position by hand by calling the "RecalculatePosition"-method on  the droptarget!  This option is advised when you have lots and lots of droptargets on one screen - in other cases, it shouldn't be necessary.
  • Added property: DropBorderBrush:
    The brush for the drop border
  • Added property: DropBorderCornerRadius:
    The cornerradius of the drop border
  • Added property: DropBorderThickness:
    The thickness of the drop border
  • Changed property: GhostVisibility:
    Changed ShowGhost (bool) to GhostVisibility (Visibility).  Determines wether or not the ghost control should be shown (default: Visible)

Bugfixes:

  • Extra checks to make sure all borders are removed when hovering is stopped - in some cases, the drop target would stay in "hovered"-mode even after the drag source had been dropped.
  • Sometimes, the animation used when switching 2 elements' position would let the elements go "underneath" other elements on the page.  This is now fixed, moving elements are always on top.
  • When clicking an element to start dragging, you'd sometimes loose the ability to drag.  This shouldn't happen anymore.
  • Various other small (performance) improvements and bugfixes.

Silverlight »

[9 Sep 2009 | 0 Comments]

As mentioned on Joe Stegman’s blog, Tim Heuer and Scott Barnes have established a feature tracker for new features we’d like to see in Silverlight 4.  The whole community can now vote for the features they’d like best on the Silverlight Feedback Forum

 

So if there’s a feature you’d really like to see in Silverlight 4, here’s your chance to let the team working on it know!  If you happen to feel like doing me a favour: vote for commanding support, please ;-)  A few other features I voted for: printing support, webcam support & Sillverlight for iPhone (or better, mobile in general).

 

What are your picks?  Let them know!

 

General, RealDolmen, RIA, Silverlight »

[7 Sep 2009 | 0 Comments]

A while ago, my company decided to launch a new marketing campaign, showing of some of the things we’ve done in the past.  To accompany this campaign, we decided to design a showcase site.  This showcase site shows of a whole lot of customer cases, technology flyers, solutions sheets, … in short: technologies and solutions we offer to our customers. 

 

We wanted this site to leave an immediate impression on everyone who visits it – and what better way to do that than by using Silverlight to build it, right? :-)

 

image

My team worked hard on building this site, and I hope you’ll like what we’ve come up with.  To have a look, point your browsers at http://www.realdolmen.com/customercases/!

 

From a technical point of view, some points of interest:

  • Silverlight 3 site (frontend & backend)
  • RIA Services & Entity Framework ORM
  • Indexability by search engines was very important to us, so we’ve incorporated some SEO techniques
  • Deep linking support
  • Custom designed “Rich Text Viewer” (and editor in the backend SL app) –> the details view markup you see when you select a case is actually generated on the fly from an XML-file!

General, WCF RIA Services, BESUG, Drag and Drop Manager »

[7 Sep 2009 | 0 Comments]

So, the holiday season is over for most of us, I hope everyone had a nice few weeks off – I know I had :-) 

 

Time to get back on track!  Quite a few things are coming up in the next days/weeks/months: a new version of the Silverlight Drag and Drop Manager is coming up (watch this space!), and one of my projects @ work is going live – it’s a showcase site, built completely in Silverlight 3; I’ll share the URL shortly.

 

Next to that, my company is hosting a session I’m doing for BESUG, the Belgian Silverlight User Group shortly, about Silverlight 3 & RIA Services.  If you’d like to be at this session, click here to register.  I’ll share the slides & code on this blog after the session.

 

And last but not least, I’m continuing work on a Silverlight book (more details later) I’m writing together with a collegue, Gill Cleeren.

 

I tend to post updates concerning these things on Twitter, so if you’d like to, you can follow me here (@KevinDockx).

 

To sum it all up: lots of work to do, guess I won’t have time to get bored the next few months ;-)

Silverlight, .NET, WCF RIA Services, RIA, WCF »

[24 Jul 2009 | 0 Comments]

When working with RIA Services, a lot of your code is generated automatically, but you'll still need to write quite a lot of custom methods and you'd typically write them in your DomainService-class.  But what if you add an Entity to your datastore?  What if you want to add some CUD-operations next to the read-operation that's been generated?  Either you'd have to write the Entity-classes and methods manually (a lot of work for something that could be generated), or you'd have to delete your DomainService and re-add it (so the newly added Entities/Queries get generated), but then you'd lose all the custom methods you've written in your DomainService...

 

Bummer, huh?  Well, luckily, there's a nice workaround for this!  Imagine you've written a DomainService filled with custom queries, ServiceOperations, ..., working on an Entity Framework domain model.  All of a sudden, a table has to be added to your domain model, so you need to regenerate your DomainService: delete and re-add, thereby losing your custom methods.  It would be nice if you could just put your custom methods in a seperate file, so deleting the DomainService wouldn't delete those methods.  And you can!  The magic word here?  Partial classes!

 

As an example, I've changed my demo-app around a bit: it now only shows the customers beginning with a certain string.  To get this behaviour, I've added a new query method, GetCustomersByFirstLetters, which accepts a string.  I'm passing this as a query to my LoadOperation when loading the items for my DataGrid:

 

   1: LoadOperation<Customer> loCustomer = CDC.Load(CDC.GetCustomersByFirstLettersQuery("a"));


 

But, instead of adding this custom method to the CustomerDomainService.cs-file, I've created a new file, and named it CustomerDomainService.partial.cs.  In this file, I define a class like this, and add my new method to it:

 



   1: public partial class CustomerDomainService : LinqToEntitiesDomainService<AdventureWorksLTEntities>


   2: {


   3:     public IQueryable<Customer> GetCustomersByFirstLetters(string firstLetters)


   4:     {


   5:         return this.Context.Customer.Where(c => c.CompanyName.StartsWith(firstLetters));


   6:     }


   7: }


 

Notice the "partial" keyword? Now, in my original CustomerDomainService.cs-file, I've also changed the class signature to include the "partial" keyword.

 



   1: [EnableClientAccess()]


   2:     public partial class CustomerDomainService : LinqToEntitiesDomainService<AdventureWorksLTEntities>


 

When you build and run this, you'll see the app behaves just as you'd expect it to - but thanks to the fact that the custom method is now in a separate file, you'll no longer lose it in case you have to recreate your DomainService.  All you have to remember is to add the "partial" keyword to the class definition of your generated DomainService, and you're done! :-)

 

What has happened here?  Well, the "partial" keyword actually tells .NET that your class has been split over multiple class definitions/files.  When you build your app, the compiler will combine all the "partial"-classes with the same signature into one class, just as if they were defined in the same file.

 

I'm pretty sure the need for deleting & recreating your DomainService will be fixed in one of the next drops (after all, the "Update from Database"-option didn't exist in the first versions of the Entity Framework either), but until then, this should be quite a handy tip.  Enjoy! :-)

 

Adjusted sourcecode has been posted here if you'd want it.