tags:

views:

64

answers:

1

Hello,

I have an issue with how to organise the the screen layout for my data.

I have a object A with properties A1 and A2 and may contain an Object B.

Object B has properties B1, B2, B3 and a collection of 1 or more of object C.

Object C contains properties C1, C2 and C3

I want the the layout to be

A1   A2

or

A1   A2  B1   B2   B3  C1   C2   C3

or

A1   A2  B1   B2   B3  C1   C2   C3

                       C1   C2   C3

I tried the following Xaml but could not get object C to occur more than once. I created a datatemplate

            <TextBlock  Text="{Binding Path=A1}" Grid.Column="0" />
 <TextBlock  Text="{Binding Path=A2}" Grid.Column="1" />
            <StackPanel Orientation="Horizontal" Name="B" DataContext="{Binding Path=B}" Grid.Column="2">
  <TextBlock  Text="{Binding Path=B1}"  />
  <TextBlock  Text="{Binding Path=B2}"  />
  <TextBlock  Text="{Binding Path=B3}"  />
  <StackPanel Orientation="Horizontal" Name="C" DataContext="{Binding Path=C}">
   <TextBlock  Text="{Binding Path=C1}"  />
   <TextBlock  Text="{Binding Path=C2}"  />
   <TextBlock  Text="{Binding Path=C3}"  />
  </StackPanel>
 </StackPanel>
        </Grid>

and use a listview using the datatemplate to display the data, but only one row of C data is ever displayed. Any suggestions on how to get the desired layout?

John

A: 

Presumably (if all assumptions that I had to make due to insufficient clarity of the question are correct), you want this:

<TextBlock  Text="{Binding Path=A1}" Grid.Column="0" />
    <TextBlock  Text="{Binding Path=A2}" Grid.Column="1" />
        <StackPanel Orientation="Horizontal" Name="B" DataContext="{Binding Path=B}" Grid.Column="2">
            <TextBlock  Text="{Binding Path=B1}"  />
            <TextBlock  Text="{Binding Path=B2}"  />
            <TextBlock  Text="{Binding Path=B3}"  />
            <ItemsControl ItemsSource="{Binding Path=C}">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Vertical" />
                    </ItemsPanelTemplate>
                 </ItemsControl.ItemsPanel>
                 <ItemsControl.ItemTemplate>
                     <DataTemplate>
                         <StackPanel Orientation="Horizontal" Name="C">
                             <TextBlock  Text="{Binding Path=C1}"  />
                             <TextBlock  Text="{Binding Path=C2}"  />
                             <TextBlock  Text="{Binding Path=C3}"  />
                         </StackPanel>
                     </DataTemplate>
                 </ItemsControl.ItemTemplate>
            </ItemsControl>
    </StackPanel>
Pavel Minaev
Many thanks .. wasn't sure what extra information was required.
John