Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

15. XAML > Review

Review

image

Can you draw the logical tree created by this XAML?

<Window Name="MainWindow">
 <Window.ContextMenu>
  <ContextMenu>
   <MenuItem Header="Item1" />
   <MenuItem Header="Item2" />
  </ContextMenu>
 </Window.ContextMenu>
 <StackPanel Name="LayoutRoot">
  <Label>Say Something</Label>
  <Button>Do Something</Button>
 </StackPanel>
</Window>

image

In the XAML markup above, find examples of attribute, property and collection syntax.

You have to do three things to make sure that the CLR can connect XAML and the code-behind. Can you pick them from the list below?

Call the Connect() method in the class constructor.

Make sure both files exist in the same namespace.

Set the Name property of objects in code.

Set the Class attribute of the XAML root element.

Give XAML elements and variables in the code the same name.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint