From the course: Microsoft XAML: 2 Content and Properties
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Content as an object in code
From the course: Microsoft XAML: 2 Content and Properties
Content as an object in code
- [Instructor] In this video, I'll look at how to set the content property of a content control in code, instead of in XAML. To do that, I'll need to have some content controls in my stack panel inside my window.XAML file I've got three buttons, those are content controls. I also have a text block, which is not a content control, but has a tooltip property, which does accept content. In order to work with these items and the code behind, they have to have a name. You see, on line 11, I'm using the x colon name attribute, and I assigned the Button2 name to this button element. Next, we'll go to the code behind, and in the constructor, I'll set the content property of the first button to a string literal. Before I type in the equal sign, I'll hover over this to show you that the type of this property is of object, which means that an instance of any dot net type can be assigned here. It could be a nonvisual class, like this string I'll be using, or it could be a visual element like an…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
(Locked)
What does content mean in XAML?3m 41s
-
(Locked)
Use children elements as content7m 5s
-
(Locked)
Install the dotPeek utility1m 16s
-
How each element defines a content property5m 28s
-
(Locked)
Content as an object in XAML6m 32s
-
(Locked)
Content as an object in code5m 33s
-
(Locked)
Visual content in panels4m 59s
-
(Locked)
Content as a list in XAML3m 53s
-
(Locked)
Content as a list in code3m 6s
-
(Locked)
Content as a dictionary in XAML4m 53s
-
(Locked)
Content as a dictionary in code1m 25s
-
(Locked)
-
-