TAILIEUCHUNG - Illustrated WPF phần 3

Nhiều yếu tố WPF hình ảnh hiển thị nội dung cho người sử dụng, chẳng hạn như các nhãn vào một nút. Tôi sẽ mô tả nội dung chi tiết hơn trong Chương 6, nhưng để thảo luận hiện tại của chúng tôi XAML, bạn cần phải biết những điều sau đây: • Mỗi lớp WPF có thể có nội dung có một tài sản được quy định như chủ sở hữu nội dung mặc định của nó. | CHAPTER 4 XAML The Default Content Property Many WPF visual elements display content to the user such as the label on a button. I ll describe content in more detail in Chapter 6 but for our current discussion of XAML you need to know the following Every WPF class that can have content has a property that is specified as its default content holder. I mentioned this a bit earlier when describing the content section of the element syntax. This default content property is specified using the ContentPropertyAttribute attribute in the class declaration. This is a .NET attribute not a XAML attribute. The declaration of the default content holder might not be on the class itself however. You might have to burrow down the inheritance tree a bit to find it. For example if you go to the documentation for the WPF Button class you won t find mention of this attribute. But if you go down past the ButtonBase class to the Contentcontrol class and look at the C section you ll find the following declaration. The parameter of the attribute contains the string Content which specifies that for all classes derived from this one it is the Content property that is the default content holder. Attribute Content Property ị ị ContentPropertyAttribute Content public class ContentControl Control IAddChild . T Class Name Different classes have different default content holder properties. For example if you were to drill down from the ListBox control to its base class ItemsControl you d find that the ContentProperty in this case is the Items property. For simple content rather than placing content between the start tag and the end tag you could use attribute syntax. For example the following markup shows four button instantiations that are semantically equivalent. They all produce identical buttons. The first button instantiation uses simple object element syntax with the content between the start and end tags. The second puts the content in the start tag by using attribute syntax. The third does

TỪ KHÓA LIÊN QUAN
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.