Prev | Current Page 136 | Next

Matthew MacDonald

"Pro WPF with VB 2008: Windows Presentation Foundation with .NET 3.5"


Content property.
nNote This limitation is a XAML detail and it won??™t affect you if you want to set the Button.Content property
in code.
Special characters aren??™t the only stumbling block you??™ll run into with XAML. Another
issue is whitespace handling. By default, XML collapses all whitespace, which means a long
string of spaces, tabs, and hard returns is reduced to a single space. Furthermore, if you add
whitespace before or after your element content, this space is ignored completely. You can see
this in the EightBall example. The text in the button and the two text boxes is separated from
the XAML tags using a hard return and tab to make the markup more readable. However, this
extra space doesn??™t appear in the user interface.
Sometimes this isn??™t what you want. For example, you may want to include a series of several
spaces in your button text. In this case, you need to use the xml:space="preserve"
attribute on your element.
The xml:space attribute is a part of the XML standard, and it??™s an all-or-nothing setting.
Once you switch it on, all the whitespace inside that element is retained. For example, consider
this markup:

[There is a lot of space inside these quotation marks " ".]

In this example, the text in the text box will include the hard return and tab that appear
before the actual text.


Pages:
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148