Nguyên tắc hàng đầu là bạn có thể sử dụng cú pháp dấu chấm khi tài sản là một loại nguyên thủy (chẳng hạn như là một chuỗi), như sau:Theo đó, bạn sử dụng cú pháp accessor khi tài sản là một đối tượng phức tạp. Cú pháp accessor sử dụng phương pháp get_ và set_ để có được và thiết lập giá trị của tài sản. | 376 CHAPTER 16 PROGRAMMING SILVERLIGHT WITH XAML AND JAVASCRIPT In addition you can set the Z-order of the Canvas using the attribute. Z-order determines which item is drawn on top of another if multiple items are overlapping on the screen. Silverlight reads a XAML file from the top down so that items that appear later in the document will be drawn on top of items that appear earlier. Here is an example of a XAML document containing two Canvases. Each Canvas contains a rectangle. Canvas xmlns http client 2007 xmlns x http winfx 2006 xaml Width 640 Height 480 Background White x Name Page Canvas Width 214 Height 145 59 8 Rectangle Width 191 Height 104 Fill White Stroke Black 19 Canvas Canvas Width 254 Height 162 69 129 Rectangle Width 211 Height 154 Fill Black Stroke Black Canvas Canvas There are a number of things going on in this listing which once you understand them will help you to understand how to lay elements out in Silverlight XAML. First notice that each of the rectangles is contained within a Canvas. The first or white rectangle the one with the Fill White attribute set has its property set to 19. This means that it will be drawn 19 pixels down from its container. Its container Canvas has a of 59 and a of 8. This Canvas is contained by the root Canvas thus the white rectangle will be drawn 78 pixels down from the top of the screen and 8 pixels from the left. Similarly the black rectangle s position is determined by its and properties relative to its container Canvas. Next you will notice that the dimensions of the rectangles are set so that they are actually overlapping and occupying some of the same screen real estate. As mentioned earlier Silverlight will draw later elements on top of earlier ones so the black rectangle should be drawn on top of the white one. Figure 16-1 shows how .