It's one thing to type in <Paragraph>some text</Paragraph>, but how do you know which property to set if you're writing it in code?
The "Content" of a XAML tag is specified by the ContentPropertyAttribute. You can easily check the attributes on a type by using "Go To Definition" in Visual Studio.
Note you have to expand the [...] in front of the class definition to see the attributes. In the case of Paragraph, we see that the "Inlines" property is set - the equivalent code would be:
Paragraph p = new Paragraph();
p.Inlines.Add("some text");
If at first you don't succeed, then try, try again. In the example of Button, the "Content" property comes all the way down in ContentControl. Keep using Go To Definition and expanding the attributes until you find what you're looking for.
No comments:
Post a Comment