Whenever I create a UIElement in code behind, I'd do something like this:
Button button = new Button();
button.Content = "Click Me!";
But then I saw this syntax somewhere, and wanted to know what it's called. I haven't ever seen it used in any of my .NET books:
Button button = new Button { Content="Click Me!" };
This is obviously nice because it's concise. So I guess my questions are:
- what's it called?
- are there any disadvantages to instantiating a UIElement in this manner?
I've also had trouble figuring out the right way to set properties like CornerRadius and StrokeThickness, and thought the answer to #1 might help me make more intelligent search queries.