Well, it's not actually the shape that is changing, it is the transform group.
So I would guess is that you have to possibly put a tag that indicates which axis the TransformGroup moves along. And then when your behavior is active, it first checks the tag, then corresponds accordingly.