Hi,
"jmagaram" <jmagaram@discussions.microsoft.com> wrote in message
news:29DEC174-5E49-4876-B333-9E848354452B@microsoft.com...
>I implemented a major hack to solve this. For each row in the parent table,
>I
> created a column of type DataView called RelatedPhoneNumbers and filled it
> with a custom built DataView. Each time a row is added to the parent
> table,
> the TableNewRow event fills in this special column automatically. Then I
> just
> set the ItemsSource property to "RelatedPhoneNumbers". There must be a
> better
> way.
>
If you add a "Person-PhoneNumber" DataRelation to the DataSet, then the
DataView of the Person table will already have an extra column (with the
same name as the relation) which returns a child DataView of the PhoneNumber
table.
HTH,
Greetings
> Ideas anyone?
>
> "jmagaram" wrote:
>
>> I have a DataSet filled with two tables:
>>
>> Person [PersonID,First,Last]
>> PhoneNumber [PersonID,PhoneNumber,PhoneType]
>>
>> I want to display a tree of each person and their list of phone numbers.
>> The
>> top level is easy - I bind to a DataView on the Person table. But I can't
>> figure out how to also show the associated phone numbers (as a DataView
>> so it
>> gets updated automatically). One idea I had was to create a Method on the
>> DataSet something like this:
>>
>> DataView GetPhoneNumbers(DataRow person)
>>
>> I don't know how to refer to this method in the ItemsSource in the XAML.
>> Binding to properties seems straightforward, but not to methods. The
>> templates look something like this:
>>
>> <DataTemplate x:Key="PhoneRowTemplate">
>> <StackPanel Orientation="Horizontal">
>> <TextBlock Text="{Binding Path=PhoneType}"/>
>> <TextBlock Text="{Binding Path=PhoneNumber}"/>
>> </StackPanel>
>> </DataTemplate>
>>
>> <DataTemplate x:Key="PersonRowTemplate">
>> <StackPanel Orientation="Vertical">
>> <TextBlock Text="{Binding Path=First}"/>
>> <TextBlock Text="{Binding Path=Last}"/>
>> <ListBox ItemsSource="?????" ItemTemplate="{StaticResource
>> PhoneRowTemplate}"></ListBox>
>> </StackPanel>
>> </DataTemplate>