Collection syntax

Sometimes it's required to define a collection of elements in the XAML. This is done using the Collection syntax to make it more readable. For example, a StackPanel can have multiple elements defined inside the Children property :

    <StackPanel> 
       <StackPanel.Children> 
          <Button Content="1" /> 
          <Button Content="2" /> 
       </StackPanel.Children> 
    </StackPanel> 

The preceding example can also be written as follows, where the parser knows how to create and assign it:

    <StackPanel> 
      <Button Content="1" /> 
      <Button Content="2" /> 
    </StackPanel> 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.154.171