How to bind an ancestor from a datatemplate generated descendantHello to the forum,<br>I have a listbox whose data source is a collection of items (collection A).<br>Every item of the collection includes itself another collection of elements (collection B).<br>I use a datatemplate to present the listbox as a stack of blocks and to display inside<br>each block a tree of elements whose data source is the collection B.<br><br>If selecting a node of the datatemplate generated sub-tree, <br>I want the container listbox item to be selected as well.<br>Is it possible to bind ancestors' properties using as source the template-generated<br>descendants' properties?<br><br>I wasn't able to find a solution for this issue.<br><br>This is the xaml of my datatempate:<br><br>&lt;DataTemplate x:Key=&quot;listBoxTemplate&quot;&gt;<br>   &lt;Grid&gt;<br>      &lt;Grid.RowDefinitions&gt;<br>         &lt;RowDefinition/&gt;<br>         &lt;RowDefinition/&gt;<br>      &lt;/Grid.RowDefinitions&gt;<br>      &lt;Grid.ColumnDefinitions&gt;<br>         &lt;ColumnDefinition Width=&quot;Auto&quot;/&gt;<br>      &lt;/Grid.ColumnDefinitions&gt;<br>      &lt;TextBlock Name=&quot;tbxRole&quot; Grid.Row=&quot;0&quot; Grid.Column=&quot;0&quot; Text=&quot;{Binding Path=ValueMember.Type.Name}&quot;/&gt;<br>      &lt;TreeView Name=&quot;subTree&quot; Grid.Row=&quot;1&quot; Grid.Column=&quot;0&quot; ItemsSource=&quot;{Binding Path=ChildrenItems}&quot;&gt;<br>         &lt;TreeView.ItemTemplate&gt;<br>            &lt;HierarchicalDataTemplate DataType=&quot;root&quot; ItemsSource=&quot;{Binding Path=ChildrenItems}&quot;&gt;<br>               &lt;StackPanel Orientation=&quot;Horizontal&quot;&gt;<br>                  &lt;TextBlock Name=&quot;linkTypeName&quot; Text=&quot;{Binding Path=ValueMember.LinkType.Name}&quot;/&gt;<br>                  &lt;TextBlock Name=&quot;linkName&quot; Text=&quot;{Binding Path=ValueMember.IdentityRefChild.LastName}&quot;/&gt;<br>               &lt;/StackPanel&gt;<br>            &lt;/HierarchicalDataTemplate&gt;<br>         &lt;/TreeView.ItemTemplate&gt;<br>      &lt;/TreeView&gt;<br>   &lt;/Grid&gt;<br>&lt;/DataTemplate&gt;<br><br>Thanks for help in advance.<br><br>Gianni© 2009 Microsoft Corporation. All rights reserved.Thu, 19 Jun 2008 00:15:52 Z3edf4900-702a-4cfc-a438-9c61622278c4http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/3edf4900-702a-4cfc-a438-9c61622278c4#3edf4900-702a-4cfc-a438-9c61622278c4http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/3edf4900-702a-4cfc-a438-9c61622278c4#3edf4900-702a-4cfc-a438-9c61622278c4Gianni.Ghttp://social.msdn.microsoft.com/Profile/en-US/?user=Gianni.GHow to bind an ancestor from a datatemplate generated descendantHello to the forum,<br>I have a listbox whose data source is a collection of items (collection A).<br>Every item of the collection includes itself another collection of elements (collection B).<br>I use a datatemplate to present the listbox as a stack of blocks and to display inside<br>each block a tree of elements whose data source is the collection B.<br><br>If selecting a node of the datatemplate generated sub-tree, <br>I want the container listbox item to be selected as well.<br>Is it possible to bind ancestors' properties using as source the template-generated<br>descendants' properties?<br><br>I wasn't able to find a solution for this issue.<br><br>This is the xaml of my datatempate:<br><br>&lt;DataTemplate x:Key=&quot;listBoxTemplate&quot;&gt;<br>   &lt;Grid&gt;<br>      &lt;Grid.RowDefinitions&gt;<br>         &lt;RowDefinition/&gt;<br>         &lt;RowDefinition/&gt;<br>      &lt;/Grid.RowDefinitions&gt;<br>      &lt;Grid.ColumnDefinitions&gt;<br>         &lt;ColumnDefinition Width=&quot;Auto&quot;/&gt;<br>      &lt;/Grid.ColumnDefinitions&gt;<br>      &lt;TextBlock Name=&quot;tbxRole&quot; Grid.Row=&quot;0&quot; Grid.Column=&quot;0&quot; Text=&quot;{Binding Path=ValueMember.Type.Name}&quot;/&gt;<br>      &lt;TreeView Name=&quot;subTree&quot; Grid.Row=&quot;1&quot; Grid.Column=&quot;0&quot; ItemsSource=&quot;{Binding Path=ChildrenItems}&quot;&gt;<br>         &lt;TreeView.ItemTemplate&gt;<br>            &lt;HierarchicalDataTemplate DataType=&quot;root&quot; ItemsSource=&quot;{Binding Path=ChildrenItems}&quot;&gt;<br>               &lt;StackPanel Orientation=&quot;Horizontal&quot;&gt;<br>                  &lt;TextBlock Name=&quot;linkTypeName&quot; Text=&quot;{Binding Path=ValueMember.LinkType.Name}&quot;/&gt;<br>                  &lt;TextBlock Name=&quot;linkName&quot; Text=&quot;{Binding Path=ValueMember.IdentityRefChild.LastName}&quot;/&gt;<br>               &lt;/StackPanel&gt;<br>            &lt;/HierarchicalDataTemplate&gt;<br>         &lt;/TreeView.ItemTemplate&gt;<br>      &lt;/TreeView&gt;<br>   &lt;/Grid&gt;<br>&lt;/DataTemplate&gt;<br><br>Thanks for help in advance.<br><br>GianniFri, 25 Jan 2008 12:11:37 Z2008-01-31T08:30:36Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/3edf4900-702a-4cfc-a438-9c61622278c4#47463420-80ec-4626-b1f4-3d4928920108http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/3edf4900-702a-4cfc-a438-9c61622278c4#47463420-80ec-4626-b1f4-3d4928920108Wei Zhou - MSFThttp://social.msdn.microsoft.com/Profile/en-US/?user=Wei%20Zhou%20-%20MSFTHow to bind an ancestor from a datatemplate generated descendant<p align=left><font face=Arial size=2>You can get ListBoxItem from TreeView.GotFocus event. The following code shows how to do this.</font></p> <p align=left> </p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left><span style="color:blue"> <div class=codeseg> <div class=codecontent> <div class=codesniptitle><span style="width:100%">Code Snippet</span></div> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left><span style="color:blue">&lt;</span><span style="color:#a31515">Window</span></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>   <span style="color:red">x</span><span style="color:blue">:</span><span style="color:red">Class</span><span style="color:blue">=&quot;ForumProjects.MainWindow&quot;</span></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>   <span style="color:red">xmlns</span><span style="color:blue">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>   <span style="color:red">xmlns</span><span style="color:blue">:</span><span style="color:red">x</span><span style="color:blue">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>   <span style="color:red">xmlns</span><span style="color:blue">:</span><span style="color:red">local</span><span style="color:blue">=&quot;clr-namespace:ForumProjects&quot;</span></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>   <span style="color:red">x</span><span style="color:blue">:</span><span style="color:red">Name</span><span style="color:blue">=&quot;Window&quot;</span><span style="color:blue">&gt;</span></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left><span style="color:#a31515">    </span><span style="color:blue">&lt;</span><span style="color:#a31515">Window.Resources</span><span style="color:blue">&gt;</span></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left><span style="color:#a31515">        </span><span style="color:blue">&lt;</span><span style="color:#a31515">DataTemplate</span><span style="color:red"> x</span><span style="color:blue">:</span><span style="color:red">Key</span><span style="color:blue">=&quot;OrderItemTemplate&quot;&gt;</span></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left><span style="color:#a31515">            </span><span style="color:blue">&lt;</span><span style="color:#a31515">TextBlock</span><span style="color:red"> Text</span><span style="color:blue">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:red"> Product</span><span style="color:blue">}&quot;/&gt;</span></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left><span style="color:#a31515">        </span><span style="color:blue">&lt;/</span><span style="color:#a31515">DataTemplate</span><span style="color:blue">&gt;</span></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left><span style="color:#a31515">        </span><span style="color:blue">&lt;</span><span style="color:#a31515">HierarchicalDataTemplate</span><span style="color:red"> x</span><span style="color:blue">:</span><span style="color:red">Key</span><span style="color:blue">=&quot;OrderTemplate&quot;</span></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>                                <span style="color:red">ItemsSource</span><span style="color:blue">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:red"> Items</span><span style="color:blue">}&quot;</span></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>                                <span style="color:red">ItemTemplate</span><span style="color:blue">=&quot;{</span><span style="color:#a31515">StaticResource</span><span style="color:red"> OrderItemTemplate</span><span style="color:blue">}&quot;&gt;</span></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left><span style="color:#a31515">            </span><span style="color:blue">&lt;</span><span style="color:#a31515">TextBlock</span><span style="color:red"> Text</span><span style="color:blue">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:red"> OrderID</span><span style="color:blue">}&quot;/&gt;</span></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left><span style="color:#a31515">        </span><span style="color:blue">&lt;/</span><span style="color:#a31515">HierarchicalDataTemplate</span><span style="color:blue">&gt;</span></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left><span style="color:#a31515">        </span><span style="color:blue">&lt;</span><span style="color:#a31515">DataTemplate</span><span style="color:red"> x</span><span style="color:blue">:</span><span style="color:red">Key</span><span style="color:blue">=&quot;CustomerTemplate&quot;&gt;</span></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left><span style="color:#a31515">            </span><span style="color:blue">&lt;</span><span style="color:#a31515">StackPanel</span><span style="color:blue">&gt;</span></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left><span style="color:#a31515">                </span><span style="color:blue">&lt;</span><span style="color:#a31515">TextBlock</span><span style="color:red"> Text</span><span style="color:blue">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:red"> Name</span><span style="color:blue">}&quot;/&gt;</span></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left><span style="color:#a31515">                </span><span style="color:blue">&lt;</span><span style="color:#a31515">TreeView</span><span style="color:red"> ItemsSource</span><span style="color:blue">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:red"> Orders</span><span style="color:blue">}&quot;</span></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>                        <span style="color:red">ItemTemplate</span><span style="color:blue">=&quot;{</span><span style="color:#a31515">StaticResource</span><span style="color:red"> OrderTemplate</span><span style="color:blue">}&quot;</span></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>                        <span style="color:red">GotFocus</span><span style="color:blue">=&quot;TreeViewGotFocus&quot;/&gt;</span></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left><span style="color:#a31515">            </span><span style="color:blue">&lt;/</span><span style="color:#a31515">StackPanel</span><span style="color:blue">&gt;</span></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left><span style="color:#a31515">        </span><span style="color:blue">&lt;/</span><span style="color:#a31515">DataTemplate</span><span style="color:blue">&gt;</span></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left><span style="color:#a31515">    </span><span style="color:blue">&lt;/</span><span style="color:#a31515">Window.Resources</span><span style="color:blue">&gt;</span></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left><span style="color:#a31515">    </span><span style="color:blue">&lt;</span><span style="color:#a31515">ListBox</span><span style="color:red"> ItemsSource</span><span style="color:blue">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:red"> ElementName</span><span style="color:blue">=Window,</span><span style="color:red"> Path</span><span style="color:blue">=Customers}&quot;</span></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>            <span style="color:red">ItemTemplate</span><span style="color:blue">=&quot;{</span><span style="color:#a31515">StaticResource</span><span style="color:red"> CustomerTemplate</span><span style="color:blue">}&quot;/&gt;</span></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left><span style="color:blue">&lt;/</span><span style="color:#a31515">Window</span><span style="color:blue">&gt;</span></p> <p align=left> </p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left><span style="color:blue">namespace</span> ForumProjects</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>{</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>    <span style="color:blue">public</span> <span style="color:blue">partial</span> <span style="color:blue">class</span> <span style="color:#2b91af">MainWindow</span> : <span style="color:#2b91af">Window</span></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>    {</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>        <span style="color:blue">public</span> MainWindow()</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>        {</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>            <span style="color:blue">this</span>.Customers = <span style="color:blue">new</span> <span style="color:#2b91af">List</span>&lt;<span style="color:#2b91af">Customer</span>&gt;()</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>            {</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>                <span style="color:blue">new</span> <span style="color:#2b91af">Customer</span>(<span style="color:#a31515">&quot;Customer A&quot;</span>),</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>                <span style="color:blue">new</span> <span style="color:#2b91af">Customer</span>(<span style="color:#a31515">&quot;Customer B&quot;</span>)</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>            };</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left> </p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>            <span style="color:blue">this</span>.Customers[0].Orders.AddRange(<span style="color:blue">new</span> <span style="color:#2b91af">Order</span>[]</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>            {</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>                <span style="color:blue">new</span> <span style="color:#2b91af">Order</span>(<span style="color:#a31515">&quot;0001&quot;</span>),</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>                <span style="color:blue">new</span> <span style="color:#2b91af">Order</span>(<span style="color:#a31515">&quot;0002&quot;</span>)</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>            });</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>            <span style="color:blue">this</span>.Customers[0].Orders[0].Items.AddRange(<span style="color:blue">new</span> <span style="color:#2b91af">OrderItem</span>[]</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>            {</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>                <span style="color:blue">new</span> <span style="color:#2b91af">OrderItem</span>(<span style="color:#a31515">&quot;Product A&quot;</span>),</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>                <span style="color:blue">new</span> <span style="color:#2b91af">OrderItem</span>(<span style="color:#a31515">&quot;Product B&quot;</span>)</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>            });</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>            <span style="color:blue">this</span>.Customers[0].Orders[1].Items.AddRange(<span style="color:blue">new</span> <span style="color:#2b91af">OrderItem</span>[]</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>            {</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>                <span style="color:blue">new</span> <span style="color:#2b91af">OrderItem</span>(<span style="color:#a31515">&quot;Product C&quot;</span>),</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>                <span style="color:blue">new</span> <span style="color:#2b91af">OrderItem</span>(<span style="color:#a31515">&quot;Product D&quot;</span>)</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>            });</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left> </p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>            <span style="color:blue">this</span>.Customers[1].Orders.AddRange(<span style="color:blue">new</span> <span style="color:#2b91af">Order</span>[]</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>            {</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>                <span style="color:blue">new</span> <span style="color:#2b91af">Order</span>(<span style="color:#a31515">&quot;0001&quot;</span>),</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>                <span style="color:blue">new</span> <span style="color:#2b91af">Order</span>(<span style="color:#a31515">&quot;0002&quot;</span>)</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>            });</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>            <span style="color:blue">this</span>.Customers[1].Orders[0].Items.AddRange(<span style="color:blue">new</span> <span style="color:#2b91af">OrderItem</span>[]</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>            {</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>                <span style="color:blue">new</span> <span style="color:#2b91af">OrderItem</span>(<span style="color:#a31515">&quot;Product A&quot;</span>),</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>                <span style="color:blue">new</span> <span style="color:#2b91af">OrderItem</span>(<span style="color:#a31515">&quot;Product B&quot;</span>)</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>            });</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>            <span style="color:blue">this</span>.Customers[1].Orders[1].Items.AddRange(<span style="color:blue">new</span> <span style="color:#2b91af">OrderItem</span>[]</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>            {</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>                <span style="color:blue">new</span> <span style="color:#2b91af">OrderItem</span>(<span style="color:#a31515">&quot;Product C&quot;</span>),</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>                <span style="color:blue">new</span> <span style="color:#2b91af">OrderItem</span>(<span style="color:#a31515">&quot;Product D&quot;</span>)</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>            });</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>            InitializeComponent();</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>        }</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left> </p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>        <strong><span style="color:blue">private</span> <span style="color:blue">void</span> TreeViewGotFocus(<span style="color:blue">object</span> sender, <span style="color:#2b91af">RoutedEventArgs</span> e)</strong></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left><strong>        {</strong></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left><strong>            <span style="color:#2b91af">ContentPresenter</span> presenter = (<span style="color:#2b91af">ContentPresenter</span>)(((<span style="color:#2b91af">StackPanel</span>)((<span style="color:#2b91af">TreeView</span>)e.Source).Parent).TemplatedParent);</strong></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left><strong>            <span style="color:#2b91af">Customer</span> customer = (<span style="color:#2b91af">Customer</span>)presenter.Content;</strong></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left><strong>            ((<span style="color:#2b91af">ListBox</span>)<span style="color:blue">this</span>.Content).SelectedItem = customer;</strong></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left><strong>        }</strong></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left> </p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>        <span style="color:blue">public</span> <span style="color:#2b91af">List</span>&lt;<span style="color:#2b91af">Customer</span>&gt; Customers { <span style="color:blue">get</span>; <span style="color:blue">private</span> <span style="color:blue">set</span>; }</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>    }</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>    <span style="color:blue">public</span> <span style="color:blue">class</span> <span style="color:#2b91af">Customer</span></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>    {</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>        <span style="color:blue">public</span> Customer(<span style="color:blue">string</span> name) { <span style="color:blue">this</span>.Orders = <span style="color:blue">new</span> <span style="color:#2b91af">List</span>&lt;<span style="color:#2b91af">Order</span>&gt;(); <span style="color:blue">this</span>.Name = name; }</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>        <span style="color:blue">public</span> <span style="color:blue">string</span> Name { <span style="color:blue">get</span>; <span style="color:blue">set</span>; }</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>        <span style="color:blue">public</span> <span style="color:#2b91af">List</span>&lt;<span style="color:#2b91af">Order</span>&gt; Orders { <span style="color:blue">get</span>; <span style="color:blue">private</span> <span style="color:blue">set</span>; }</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>    }</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>    <span style="color:blue">public</span> <span style="color:blue">class</span> <span style="color:#2b91af">Order</span></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>    {</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>        <span style="color:blue">public</span> Order(<span style="color:blue">string</span> id) { <span style="color:blue">this</span>.Items = <span style="color:blue">new</span> <span style="color:#2b91af">List</span>&lt;<span style="color:#2b91af">OrderItem</span>&gt;(); <span style="color:blue">this</span>.OrderID = id; }</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>        <span style="color:blue">public</span> <span style="color:blue">string</span> OrderID { <span style="color:blue">get</span>; <span style="color:blue">set</span>; }</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>        <span style="color:blue">public</span> <span style="color:#2b91af">List</span>&lt;<span style="color:#2b91af">OrderItem</span>&gt; Items { <span style="color:blue">get</span>; <span style="color:blue">private</span> <span style="color:blue">set</span>; }</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>    }</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>    <span style="color:blue">public</span> <span style="color:blue">class</span> <span style="color:#2b91af">OrderItem</span></p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>    {</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>        <span style="color:blue">public</span> OrderItem(<span style="color:blue">string</span> product) { <span style="color:blue">this</span>.Product = product; }</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>        <span style="color:blue">public</span> <span style="color:blue">string</span> Product { <span style="color:blue">get</span>; <span style="color:blue">set</span>; }</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>    }</p> <p style="font-size:9pt;background:white;margin:0px;color:black;font-family:Courier New" align=left>}</p> <p align=left> </p></div></div> <p align=left> </p></span> <p></p> <p align=left>Best Regards,</p> <p align=left>Wei Zhou</p>Mon, 28 Jan 2008 08:19:42 Z2008-01-31T08:30:35Z