XAML Layout: Touchable, Visible, and Layout


Well-known member
Mar 16, 2011
Programming Experience
Of all the things involved in writing a Windows Phone 7 app, the one that by far causes me the most problems and frustration is the layout using XAML. In order to layout the elements, many of them need to be adjusted from their natural position to a more precise position. The only way I have been able to find to do this for most of my situations is to use the Margin (and when available, Padding) properties (using both positive and negative values). The only problems with this are:

1. Even though this can sometimes move the current element to the desired position, it can sometimes affect the calculated layout position of another element, causing you to need to manually edit the positions of multiple elements, which can be very frustrating if elements are dynamically added and/or removed.

2. Although the element may now be desired position visually, the associated area that is touchable may be shifted or resized (I have had many situations, sometimes even in apps I downloaded, in which I would touch slightly ABOVE a button rather than directly on it).

The first I can usually find a way around, or at least find a compromise or a slightly modified design for, but #2 is a major problem for me. This is because it can confuse the user as well (when I first started developing apps, I was extremely confused as to why a button worked when I touched it's upper part or above it, but not when I touched it's lower area). This wouldn't be a problem if all you needed was a bunch of boring text and buttons with plenty of space between them, but on devices such as the phone, you need to put things close enough together that you can get enough on the screen (but not too much stuff, as any good designer knows). However, with that much stuff on the screen, it will not be easily usable if what you touch on the screen is not interpreted as touching what the developer intended. Can anyone give me some guidance on how to do more precise positioning? Any help would be appreciated. Thanks.
Top Bottom