New Life, New Work and First book

It is curious how things can change in a short time…

In just one year I moved from Barcelona, Spain to Zurich, Switzerland to work as software developer for Roche Diagnostics, through Accenture Switzerland.

Barely one month before moving I had committed to do one of my goals in life, to write a book. Today I got the great news of its official release and worldwide availability. I have been an author before, for several professional magazines, writing countless articles but as a book, this is a first. 

Microsoft .Net Framework 4.5 Quickstart Cookbook
Microsoft .Net Framework 4.5 Quickstart Cookbook

For me it is a very important step – one well given with good content and quality – and part of a series of steps and goals I have been accomplishing through this previous years. More will come but let’s leave this for further blog posts that, from now on will become more frequently. 

Now, I’d like to copy my acknowledgments of my book as they say communicate properly my feelings and thanks.

“I’d like to first of all thank my girlfriend, Sandra Saenz Gonzalez, for her enormous support in taking on the project that this book was. I am greatly thankful for her constant understanding while having me closed up between four walls as I wrote and developed its contents. Thanks, Sandra, I love you.

Big thanks as well to my friend Jesus Salillas, who helped me with style reviews and guidance.
There are many good people out there who I have to thank, too. Thanks to Alfonso Rodriguez, who encouraged me to get into this “big .NET community world,” and to Cristina Gonzalez, who has been my MVP Lead for—wow!—6 years already; easier said than done. Additionally, there is my good friend Paco Marin, who encouraged me strongly to write for him and his magazine, DotNetMania, now DNM, and during these years of collaboration, while writing for him, we have become good friends; thank you for all your support and care.
On the way, I found great friends out there, versed in the community, who allowed me to jump right at my passion. Thanks to the INETA guys, Damir Tomicic, Tomislav Bronzin, Sander Gerz, Andrej Radinjer, Andre Obelink, Christian Nagel, Dobrisa Adamec, and, of course, Miguel Lopez. Thank you for being there and doing what you do, greatly empowering the European developers’ community. And for letting me take part in it and letting me “live it.” One simple 
I’d like to give a big thank you to the staff of Packt Publishing for this opportunity, their support and patience on bringing this together, and for their understanding concerning my move to Switzerland, which had me a bit lost for a while (regarding the book). There you showcased that you are truly valuable, as a company and as people; special thanks to Rashmi Phadnis, Amey Sawant, and Dayan Hyames.
And finally I would like to thank Layla Driscoll, former Product Manager of the .NET CLR team, and Leon Welicki, Program Manager of the Workflow Foundation, both of whom I have had the honor of having as technical reviewers for this book. Thanks! It’s awesome to count on you as reviewers.

I also have some friends who believed in me and encouraged me to write and said “I could do it”—thanks Braulio Diez, David Nudelman, Luis Franco, David Salgado, and Luis Fraile 
for your friendship, belief, and support.
I wouldn’t have been able to write enclosed in the 15 square meters—my home for almost four months of my initial stay in Switzerland—if I couldn’t take my stress out, which I did with my friends at Crossfit Zurich, so I want to give a big thank you to Ozi, all the coaches, and friends I have found at the “box” for being there!
And I will end by thanking those who started it all for me, that is, thanks to my father and mother for giving me birth and making me so curious; love you.
Thank you all!”


Silverlight’s 3D True power – from 0 to hero in 40 min.

Today, Wednesday, I’ll be talking at TechEd Europe 2010 about Silverlight 3D Actual capabilities and how to use them with the session named “Silverlight’s 3D true power – from 0 to 100 in a practical way”,  the time is 1:20pm and it will be at Hall 7.1c, Paris 1.


Why 3D? Because it is important for all of us, first we are made to interact with our environment in 3D, our interfaces have 3D tactile capabilities, our vision is 3D and 3D is natural to us (even we have been educated for some years to use 2D interfaces). But.. this is changing, all the industry is switching to 3D, starting by the gaming industry that started with the Wii and now is taking a new step with Kinect as a full body 3D scanner that allows us to interact with our full body with the Xbox interface & games, The Movie industry is also moving to 3D and the display & TV industry is doing so as well… so, it is clear that 3D is important and also the point is that any User interface technology must support this evolution & provide 3D capabilities, for creating 3D interfaces and hopefully in short time, to interact in 3D with them without any device. (So.. when a Kinect for Pc, Microsoft? J – I`m already on the Queue…)

On the session that I am proposing you, we will see the actual status of Silverlight regarding 3D, I’ll show you the basics & ABC of Silverlight 3D capabilities, we will see how do their PlaneProjection properties get along & implement some simple effects and see how we can improve them with Blend so they can shine.

Next, we will get into implementing an intermediate Interaction Design pattern that I love, the Carousel – I’ll show you how to do it from scratch and in full 3D and provide a basic animation so it can spin. Next we will improve its interaction providing it mouse interaction so it spins quicker or slower depending on how far is the mouse cursor from the center. Also we will add some control for when the mouse gets out of the interaction area, so it does not start spinning like crazy (I can bet you have seen more than one of these in production websites…).

Regarding the Carousel, you curious people can read more about it here:, here: and here: and some more… ,

Basically allows a user to select one item between a collection of items. This is good because it represents visualy the item (with picture, text & other iconic information) providing accurate understanding of the items to select & also a quick selection of them. This can be done in multiple ways, being one of the most famous the horizontal 2D carousel, the growing one that some OS have for its main function selection, the circular elliptic carousel is also very famous, but who does not know the “CoverFlow”? it is indeed a 3D representation of an horizontal Carousel – by the way, have you checked the Silverlight Booth Demo launcher? It is a nice implementation of this Interaction design Pattern, too! – you can see it at the Silverlight Booth or here: (note: it is meant to be run in full screen mode). I also implemented there an “auto” mode so I am happy with that, it is simple and efficient. Oh, and the full source code is here:

Note that it uses some code from the Bouncing Plane Demo (Henry Han, Tim Heuer, see: ) and the for the Horizontal Carousel I’ve used the Flow Layouts Library, see from Simon Ferquel, awesome work both of them!!

Oops, almost forgot, For the circular animation I have used the smart technique conceived by John Bruin – – Thanks John!


Also, there’s still more, we will see what do we have apart from the core framework, showcasing two amazing components for providing full 3D, the first being Balder a pretty nice Open Source engine friendly with Blend & XAML based and the second, Silvermotion, a commercial component with awesome power, performance & ease of use.

And yes, all this in 40 minutes.

Sounds good? J


Session Code: WEB202-LNC

Session room: Hall 7.1c Paris 1

When: Today, 1:20pm


Don’t miss it!!  If you are interested in 3D, Silverlight and in learning how to implement 3D Interaction design patterns.. we will dedicate a whole 40 minutes to this!!

Mobility days sessions & demos

Hi, first things first, thanks so much to the organizers & sponsors of the Mobilitydays event ( for celebrating such great and interesting event.

Second, as promised, here are the slides & demos with full code.

First, the slides:

Developing WP7 Applications with Silverlight –

Developing WP7 Games with Silverlight –

And do not forget to check the demos, all together in a single compressed file for your ease.

Thanks & Have fun!!

MIX 10K Entry Techniques for reducing Silverlight code and XAML size


As commented here are the full techniques I have applied for reducing the size of my MIX 10K entry, the “Silverlight Magic Lantern”, which can be found at the url

The main basis of my entry was “to surprise” and that’s not easy being this the MIX Conference & MIX Online assistants a mix of Designers and Developers, some 100% developers, others 100% Designers and some rare cases 50% each – or even more rare cases 60 to 70% each…

As for my entry to comment that it has tried to combine both wow factors, having coded in less than 10kb the following techniques:

– Bing search engine integration through REST.

– Usercontrol creation (for the knob) in very very small piece of code..

– Inverse kinematics programming – which btw I had never done before J. I’d like to thank Jeff Paries for his great book which covers some techniques on the matter… Btw, I bought the Flash Book as I did not know that there was a Silverlight one J. Now I have both.. you can get it here – with no commission 😉

– Magnifier effect – which was done initially with a shader (way cooler) and next with a writable bitmap in order to weigh less bytes L.

– Position the magnifier exactly where the inverse kinematics extreme was – that is no easy, believe me..

– Parallax effect with inverse-moving shadows, to provide a depth effect from the main front panel to the results at the back – At the end I had to take out the shadows in order to get more space available… L

Also I wanted to surprise graphically so I had the idea of enabling “skin interchange” but, sadly I had to take it out and let only one skin in place.. the nicest one of course… anyway it was way simple as it required only changing the source of the 6 images my entry uses… and it was implemented through a knob too ;).

Both of that got me the edge (I hope so at least) of being able to surprise both Designers and Developers.. and hopefully the Judges too – Anyway there are pretty good entries this year so, the best one will win!!! Good Luck to you all!!

Aaand… I will release the code (the one that is not fully compressed) in short so keep tuned…

The Techniques…

As, for the main topic of this post, the techniques used to reduce code size have been, in order of precedence:

1. Common sense à Taking out code not used, comments, blank lines, etc.

2. Use of Var if the type name declaration is bigger…

3. In some cases use global variables so they haven’t got to be declared over and over. I had to do some metrics to see how much I was using an int variable to see how much space it was taking and declare it globally. Not the thing you do in your everyday code..

4. Use Inline if’s instead of normal if’s.

5. If you apply a compare rule more than once, package it in a Boolean ;):

If you have:

If ((a ==b) &&( c!=z))&….


If ((a ==b) &&( c!=z))&….

You can do

G = ((a ==b) &&( c!=z))

And make

If (G & … everywhere else..

6. Change constants defined by its direct value that is depending on the length of its value and its use, obviously.

7. Reduce functions using anonymous functions. For example:

nextSegment.MouseLeftButtonUp += new MouseButtonEventHandler(nextSegment_MouseLeftButtonUp);

void nextSegment_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { zoomActivated = false; }

Can be converted into:

nextSegment.MouseLeftButtonUp += delegate(object s, MouseButtonEventArgs e){ zoomActivated = false; };

8. Use Object & Collection Initializers, like:

ksi.go(new List<string>() { “Small”, “Medium”, “Large” }, “Size”);

9. Reduce functions size c hanging the default parameters sender by s for example, as the previous code piece.

10. Reduce the use of the usings, that is easily done by deleting/commenting them all and resolve all the dependencies manually.

11. Use Alias on the usings, but be careful, be aware this is only necessary in the case you have to write the entire namespace path in case of conflicts with a declaration of the same name.

12. Subclass a class you are using with just the signature – I did end up not using this as it was not worth it.

13. Reduce the use of XAML files – for example, app.xaml is not really needed.

14. Reduce app.xaml.cs size -à most of its code can be greatly reduced. Mine ended looking like this:

public class App : Application


public App()


StartupEventHandler ha = null;

if (ha == null)


ha = delegate(object s, StartupEventArgs e)


base.RootVisual = new mh();



base.Startup += ha;



15. Minimize XAML Code: there is a lot of code that Blend adds and it is not necessary, there is also a lot of code pieces that are set up but also are default so taking them out does not affect the render.

16. Refactor the variable names, function names, and all the other names! I recommend that this is done first in a 3 to 6 length name so it still has some meaning – at the end you can refactor that to only 1 or 2 characters if needed… So you can touch the code with full understanding of what you have coded J.

17. Use only one – C# file 😉 – that will help reduce even more the use of the usings & also the own size of the extra files usage. This will reduce the namespace definition and usage to only one.

18. As the final step I compressed the code, I coded a simple tool that took a file and got all the whitespaces, carriage returns, etc.. it’s about 3 to 6 hours coding something like that.


Other ideas..

Other ideas I had but did not use but I think it’s cool to mention them :D:

1. Compressing the XAML

Compress the xaml (zip it) and uncompress it in runtime and render it over user control placeholders. As Silverlight comes with a compress/decompress utility the code needed for this is really small! I even looked up for the best way to do this (check this great post: but the point is that I have to do whatever the “Initialize component does”. In my case is this:


public void InitializeComponent() {

if (_contentLoaded) {



_contentLoaded = true;

System.Windows.Application.LoadComponent(this, new System.Uri(“/bml;component/IKSegment.xaml”, System.UriKind.Relative));

this.LayoutRoot = ((System.Windows.Controls.Canvas)(this.FindName(“LayoutRoot”)));

this.ScaleSegment = ((System.Windows.Media.ScaleTransform)(this.FindName(“ScaleSegment”)));

this.RotateSegment = ((System.Windows.Media.RotateTransform)(this.FindName(“RotateSegment”)));

this.IKSegmentImage = ((System.Windows.Controls.Image)(this.FindName(“IKSegmentImage”)));

this.brazo = ((System.Windows.Controls.Image)(this.FindName(“brazo”)));


Which is not small code and it is unclear that this will end up giving me the edge… 😉

That technique is only for xaml intensive applications… but will keep this for next year’s MIX 10K :D.

1. Compressing different CODE pieces and compiling/running it “on the go”

Other technique I put my eye on was to have code zipped and unzip and make it run on the client but… it just can’t be done L it needs to travel back to the server, be compiled and returned to the client, then attached and et voila! It lives! This way would make the application to atone with the rules as all the code used would be in the XAP file – it just will be transferred to the server, compiled and returned back as an assembly J. I explored this for my Magnifier Tool but ended up not using this as there was no time and still had some “basic code compression” techniques to try out.

Anyway if you are interested, this is the best reference I found on how to apply this technique: Thanks Nokola!

At the end..

Hope you enjoyed the article, if you liked it I’d like to get your feedback, maybe with a comment? J

Thanks for reading!!

Fighting with VS 2008 SP1 Beta…

Two days ago, for writting an article about Silverlight integration with ADO.Net Data Services I decided to install Visual Studio 2008 Service Pack 1 (Beta!), just to find that after the install, that went wrong and with problems it got dll problems with Silverlight 2 beta 2…

I’m still at it as I did it at once in my two computers, Desktop (Vista ultimate sp1 (x64) and Laptop (XP SP2) and all are being “in processs” right now…

There are loads of information about this issue, being the main one and recommended at the Silverlight official website, there is some very interesting information at the Scott Gutrie’s blog, and others like the Web developers blog, And also there is an interesting article on  how to download all the SP1 (also mentioned on the sp1 documentation)..

Also, be sure to read the Visual Studio Service Pack 1 Beta documentation, it is worth it. As Agent 86 said, did you read the 467th page? 😉 Just joking but would be great if things weren’t sometimes so complicated..

As on where am I now, I did all the repairs and followed procedures on my laptop but somthings not working so I am uninstalling all and will install the sp1 again.. if that doesn’t work, will do this from a clean (again) Visual Studio 2008 Professional install..

As on the Desktop, I already did this (quad core & 8 Gig ram helps on this matters) and had issues installing the sp1 as it didn’t recogniced there was a Visual Studio installed… to say I had VS Team System 2008 and thinking this was for this, I unistalled and installed the professional version.. but still doesn’t find it! and it is installed!! so I am downloading the vs 2008 sp1 manually to try installing it piece a piece… let’s see..

If anybody wants to suggest other way of actions, I’m fully open..

For now, these are my 5 cents..

Silverlight 2.0 Beta Backwards compatability problems

Recently, doing some updates and modifications to a Silverlight 1.0 AdverSite application, after installing the 2.0 beta, I found that the TextWrapping property doesn’t (by now) support the WrapWithOverflow value…

 I attach the error message for more detailed information:

 error with TextWrapping property

Also have found some strange clipping when some canvas or UI element gets out of the bounds, it doesn’t get rendered properly as it is hidden… and had some random errors and some properties didn’t get properly assigned…  By example I was creating some UI elements dynamically and they got rendered well but not in place…

I hope these issues get solved and corrected on the final version, as backwards compatibility is a very important thing that should be taken care of properly.

Ok, this is a Beta, but wanted to share my 2 cents.


Anyway great job with this technology, it is starting to look great 😀