Skip to main content

Shadows in a Windows 8 App

This week I receive a question related to XAML and a Modern UI Windows 8 application (Metro Apps).  They need a method to draw shadows in a XAML application.
When the design team port an application from iPad to Windows 8, they try to reuse a lot of things that were used on iPad. Because of this elements like shadow can appear very easily in the design of a Windows 8 application. In theory, a Windows 8 application should not contains shadows. Because an app for Windows 8 should have a clean and simple design, shadow is saw like an element that will only load the UI.
Also, people that worked with UI effect already know that the shadow effect is one of the effects that use a lot of resources – especially video or processor resource. Having this kind of effects on a tablet could drain our battery very easily.  
This is why the XAML don’t contains any kind of support for shadow. You can make some hacks, using lines with different bluer levels and thing like this, but it will be only a hack. By default we don’t have support for this kind of effect.
The first thing that we should do when we receive a request like this is to send back the design and explain that a Modern UI Windows 8 App should not contains shadows.
If you really want the shadow effect you should try using DirectX in combination with C++. Using DirectX from C++ you can make any kind of effect you want. Yes, the implementation is not so trivial, but you will obtain the perfect shadow effect. Because you are using DirectX the performance will be pretty good.
If you don’t want to use C++ and DirectX directly, I recommend . This is an open source project that offer support for DirectX from C#. They have a version of the frameworks that works pretty good on Win RT. The only thing that you should remember about Sharpdx is the performance. Because is only a wrapper over DirectX and C++, if you have any kind of problems you should fallback to C++ and write your own code.   


  1. So it seems that on iPads people are not concerned that a ... shadow might consume the battery? :)

    1. This was a big problem on SL also. In a perfect world we would have XAML integrated 100% with DirectX feature. We are on Windows now. :)


Post a Comment

Popular posts from this blog

ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded

Today blog post will be started with the following error when running DB tests on the CI machine:
threw exception: System.InvalidOperationException: The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See for more information. at System.Data.Entity.Infrastructure.DependencyResolution.ProviderServicesFactory.GetInstance(String providerTypeName, String providerInvariantName) This error happened only on the Continuous Integration machine. On the devs machines, everything has fine. The classic problem – on my machine it’s working. The CI has the following configuration:

TeamCity.NET 4.51EF 6.0.2VS2013
It seems that there …

How to check in AngularJS if a service was register or not

There are cases when you need to check in a service or a controller was register in AngularJS.
For example a valid use case is when you have the same implementation running on multiple application. In this case, you may want to intercept the HTTP provider and add a custom step there. This step don’t needs to run on all the application, only in the one where the service exist and register.
A solution for this case would be to have a flag in the configuration that specify this. In the core you would have an IF that would check the value of this flag.
Another solution is to check if a specific service was register in AngularJS or not. If the service was register that you would execute your own logic.
To check if a service was register or not in AngularJS container you need to call the ‘has’ method of ‘inhector’. It will return TRUE if the service was register.
if ($injector.has('httpInterceptorService')) { $httpProvider.interceptors.push('httpInterceptorService&#…

Fundamental Books of a Software Engineer (version 2018)

More then six years ago I wrote a blog post about fundamental books that any software engineer (developer) should read. Now it is an excellent time to update this list with new entries.

There are 5 different categories of books, that represent the recommended path. For example, you start with Coding books, after that, you read books about Programming, Design and so on.
There are some books about C++ that I recommend not because you shall know C++, only because the concepts that you can learn from it.


Writing solid codeCode completeProgramming Pearls, more programming pearls(recommended)[NEW] Introduction to Algorithms


Refactoring (M. Fowler)Pragmatic ProgrammerClean code[NEW] Software Engineering: A Practitioner's Approach[NEW] The Mythical Man-Month[NEW] The Art of Computer Programming


Applying UML and Patterns (GRASP patterns)C++ coding standards (Sutter, Alexandrescu)The C++ programming language (Stroustrup, Part IV)Object-oriented programming (Peter Coad)P…