Skip to content

Whitespace preservation in XAML

March 19, 2007

Fil asked about Collapsed Spaces Around <Run />

 

Using XamlPad, I was not able to reproduce this problem…all 6 hello worlds have spaces in them.

What is your repro?

<Page
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:System="clr-namespace:System;assembly=mscorlib">
 <StackPanel>
 <TextBlock>Hello World</TextBlock>
 <TextBlock><Run>Hello</Run> <Run>World</Run></TextBlock>
 <TextBlock><Bold>Hello</Bold> <Italic>World</Italic></TextBlock>
 <FlowDocumentPageViewer>
 <FlowDocument>
 <Paragraph>Hello World</Paragraph>
 <Paragraph><Run>Hello</Run> <Run>World</Run></Paragraph>
 <Paragraph><Bold>Hello</Bold> <Italic>World</Italic></Paragraph>
 </FlowDocument>
 </FlowDocumentPageViewer>
 </StackPanel>
</Page>
The SDK documents Whitespace Processing in XAML

Update: Corrado Cavalli, an MVP from Italy that I met last week, sent me mail pointing out a sample that reproed for him. Since it didn’t repro for me in XamlPad, but he sent a picture, I decided to check to see if compiled xaml had the problem.  It turns out that xaml and baml are consistent however I believe that this only repros in "Cider" in the March CTP.  I’ll work with the Cider team.  Thanks!

From → XAML (non-UI)

4 Comments
  1. Unknown permalink

    Sadly, I didn\’t save the repro, but I did find this one (the key was no space between the Runs):
     
    &lt;Paragraph&gt;&lt;Run&gt;Hello &lt;/Run&gt;&lt;Run&gt; World&lt;/Run&gt;&lt;/Paragraph&gt;

  2. Unknown permalink

    Sigh — you never know when markup is escaped or not. Here you go:
     
    <Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot; xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <FlowDocumentScrollViewer>  <FlowDocument>   <Paragraph><Run>Hello </Run><Run> World</Run></Paragraph>  </FlowDocument> </FlowDocumentScrollViewer></Page>

  3. Unknown permalink

    BTW — that repro definitely complies to the rules in the markup, so I wouldn\’t suggest changing it at all. I\’ll see if I can recall the original …

  4. Rob permalink

    See my update to the post above…this is a known issue in Cider (but doesn\’t affect xaml or a compiled project)…
    Let me know if you find any other bugs…  I\’m glad this one appears to be in Cider, which still hasn\’t shipped…so this is easy to fix.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: