WPF Reflections

September 23, 2008  3:38 PM

Xbap WPF – using WCF and Entity Framework

Mark Shurmer Profile: MarkWPF


That’s my advice.

I have been trying to get the combination of partial trust Xbap WPF appliction talking to a basicHttpBinding WCF service.
That’s not too hard.

What is hard is then getting that to talk to Entity Framework in partial trust (well it actually was medium trust IIS host of the WCF service).
It complained about a property IsReference which needed full reflection permission.

I ended up scrapping the EntityFramework bit , after losing much hair, and reverting back to Linq for Sql.
Now Linq for Sql also needs reflection permission, but I did manage to get it working – unlike the EntityFramework version.

It may of course been me doing something daft, but why do these technologies not get tested in partial trust????????

September 23, 2008  3:31 PM

Composite WPF – Caliburn framework

Mark Shurmer Profile: MarkWPF

In a previous blog, I talked about what a Composite application and framework is.

The Caliburn framework is a Composite framework for WPF, but built from the ground up to work for WPF.

It has been created as an open source project by Rob Eisenberg

So far, i have only read the documentation.
Documentation I heard you cry, that’s better than most open source projects already.

Sadly, I think it will be taken over by Composite WPF/Prism, as they have greater resources.
However, we should applaud Rob for the great work he has done on Caliburn and has no doubt influenced many great software developers out there using WPF.
Also, it does seem to provide extra functionalit, which could be used on top of Prism

September 19, 2008  3:35 PM

Composite WPF – SCSF

Mark Shurmer Profile: MarkWPF

In a previous blog, I talked about what a Composite application and framework is.

SCSF is the Smart Client Software Factory and has been around, in a couple of guises, for a while.
It started out life as the Client Application Block, and then became Smart Client.

Now it has been given the Software Factory treatment which has improved it’s use, as you can right click on a project or solution and create appropriate elements – like view model and presenter in one go.

It also allows you to create Views as WPF UserControls, which is great. Also, you can create all of the good stuff in WPF like commands , routed events etc.

The only bad thing is that the application that gets generated is a Windows Forms exe. That enables it to support MDI as well as tabbed MDI and SDI, so not that bad!

It’s not a bad idea if you want MDI out of the box as a method of display

September 19, 2008  3:22 PM

Composite WPF

Mark Shurmer Profile: MarkWPF

Just what are Composite applications, and why do they apply to WPF?

The principal behind Composite applications is that you want to break down a large application into small pieces, and then those pieces are glued back together.
The advantages of doing such are so taken for granted that we all do it anyway in just about any application of any size.
We’ve all created UserControls or Custom controls that encapsulate the logic and process needed – without the need for any frameworks.

The big thing about Composite applications (and the frameworks therein) is that they allow you to concentrate on building the application piece by piece without worrying about how to glue it together. The glue just works!

One other big advantage is that you don’t need to worry about whether to use SDI or MDI or Tabbed MDI, as with Composite frameworks you can switch very easily. Also in building your View or form, you don’t need to add plumbing code for the MDI or SDi stuff.

Are there any composite frameworks for WPF?

There are three that I know of: Caliburn, SCSF and Composite WPF (previously called Prism)

September 18, 2008  2:17 PM

WPF – running XBAPs in partial trust

Mark Shurmer Profile: MarkWPF

This is more difficult than it should be, quelle surprise :-)

What do I actually mean?

An XBAP is a WPF browser application, and the XBAP is actually an xml document that tells internet explorer and presentationhost.exe how to host the WPF application.

As the whole idea of the XBAP application is to run in the browser, not unreasonably it runs in a security sandbox.
The problem lies with any control that uses special permissions (guilty = datagrid in WPFToolkit) or if you try to use anything in WCF other than basicHttpBinding or wsHttpBinding (with most things turned).

The trick for WCF is to make sure that the xbap project runs from the same web root as the wcf project.
Not even silverlight is this restricted – why oh why can’t we use duplex http or similar wcf with xbap????

Anyway there is an excellent article by someone here, it shows you how to set up your xbap and wcf projects

August 31, 2008  10:38 PM

WPF Animations – PointAnimationUsingKeyFrames

Mark Shurmer Profile: MarkWPF

Another key aspect to WPF animations is the ability to specify point movements.
What do I mean by that?
Well a point can be defined as a x and a y co-ordinate, and a movement is simply an animation.

What is key to this though, is that it enables you to easily animate shapes along a specified set of co-ordinates.
Try to imagine doing that in MFC!

Here is an example of moving a circle along a series of co-ordinates:


August 31, 2008  9:34 PM

WPF Animations – KeyFrame animations

Mark Shurmer Profile: MarkWPF

With WPF animations, as well as linear ones you can also have keyframe animations.

What are keyframe animations?
Well, they allow you to control the animation changes of state completely.
You specify all of the steps, by providing a value and a time that that frame pertains to.

An example should help. Here is a sting animation (yes :-)) that has a number of key frames specifying different strings:


August 31, 2008  8:59 PM

WPF Animations – RepeatBehaviour property

Mark Shurmer Profile: MarkWPF

The RepeatBehaviour property allows you to specify how long the animation will repeat.

You can do this either as a TimeSpan or you can choose to specify Forever.

If you specify Forever, funnily enough it repeats the animation and carries on repeating it.

If however you specify a TimeSpan, you can choose a multiple of the duration or a fraction.

In the following example, the top ball repeats 1 and a half times and the bottom one forever:


August 25, 2008  10:29 PM

WPF Animations – FillBehaviour property

Mark Shurmer Profile: MarkWPF

FillBehaviour is a handy little property when you are doing animations.
It specifies what happens when the animation ends.

It’s actually an enum, and you can specify the following values:


HoldEnd will keep the ending value of the animation, whereas Stop will revert back to the original value.
That’s a somewhat bizarre naming in my opinion.
Also, I assume that there are new values expected in the future.

In the following example , two circles move across the screen a bit.
Notice how I use a Canvas in order to specify the Left property for the circles and also the syntax for specifying them in the animations.

The top circle stays where the animation finished, whereas the bottom one goes back to the original value:


August 24, 2008  6:15 PM

WPF Animations – Slow down then speed up

Mark Shurmer Profile: MarkWPF

One thing that struck me when I was first looking at the AccelerationRatio and DecelerationRatio properties in animations, was whether they could be combined to give the animation a double wobble?!?

Of course is the answer.
In the following example, observe how the bottom ellipse is out of step with the top ellipse.

The bottom ellipse is having an acceleration factor and a deceleration factor applied to it, which gives it a curved animation:


Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: