A: 

Have a look here

It seems it'll be easier to do in XAML. Unless you really need it in the code behind.

Tony
+1  A: 

You create an Effect by inheriting off of the Effect class or more likely the ShaderEffect class.

You can then create a new instance of your Effect class and assign it the Effect property of a control.

(Note if your effect is actually a Drop Shadow Effect there is already a builtin effect for that).

AnthonyWJones