Detect Orientation

Dec 30, 2010 at 2:55 AM

How do I detect the screen orientation in my view model???

Dec 30, 2010 at 3:33 AM

I'm not sure what the best way to do that is. However, consider whether your ViewModel should be aware of the orientation. That's typically a View concern.

Dec 30, 2010 at 3:35 AM

Well, I want to dynamically set the size of a textblock inside a stackpanel based on the orientation.  For some reason if I don't set a width it just runs into a straight line and gets clipped (even with textwrapping on).  So I figured if I know the orientation, I can change the width.

Know of a better way?

Dec 30, 2010 at 12:14 PM

If it is a view-specific issue, consider using a converter to bind the Orientation to the Width value.

Unless some complex logic is involved (or this behaviour should be part of your application view-model) I would just solve the issue in the view domain, without bothering the view-model.