views:

157

answers:

2

Given the following two options:

<ContentControl>Content</ContentControl>

vs.

<ContentControl Content="Content"/>
  1. Any performance differences?
  2. What would you say is more readable?
  3. Conclusion?

I'm affraid this question might sound somehow babyish, but how will I know if I won't ask, so I decided to shoot it.
Comment me if I chose the wrong decision ;)

+2  A: 

Just as a personal preference, I vote for

<ContentControl Content="Content"/>

but only because I find it more readable. AFAIK there is no performance impact by choosing one or the other, but I haven't done any testing to substantiate that...

IanR
+6  A: 

The two are identical, in terms of what is generated. The performance will be identical.

The first option, however, let's you put something that isn't directly generated via a simple text string or a markup extension, such as:

<ContentControl>
  <StackPanel>
    <TextBlock Text="Content" />
    <Image Source="SomeImage.png" />
  </StackPanel>
</ContentControl> 

If, however, you're only putting in a single text string, I find the second more readable.

Reed Copsey
I am glad to see I think like you guys..
Shimmy
???? WTF? ........
Reed Copsey
Weird, I would just like to state this would be the better answer as it is the correct reason!
DeanMc
Yeah, well, it's the more complete reason, at least.
Reed Copsey
this gotta be the right answer!
CodingTales