Help needed with DataTemplate

May 26, 2011 at 3:51 PM

I want property editor to display a collection of points either as cartesian XYZ  or cylindrical RAD values. So I have defined several Editors

<my:PropertyEditor Grid.Row="1" MinWidth="300" MinHeight="200" Margin="5,0" x:Name="wpfPropertyGrid1" >
         <my:PropertyEditor.Editors>
                 <my:TypeEditor EditedType="{x:Type Point3DCollection}" EditorTemplate="{StaticResource VectorPathEditor}"/>
                 <my:TypeEditor EditedType="{x:Type mylib:CylindricalCollection}" EditorTemplate="{StaticResource CylindricalPathEditor}"/>
                 <my:TypeEditor EditedType="{x:Type Collections:IList}" EditorTemplate="{StaticResource DatagridEditor}"/>
         </my:PropertyEditor.Editors>
  </my:PropertyEditor>

with the following DataTemplates

 <DataTemplate x:Key="DatagridEditor">
            <DataGrid Name="PointDataGrid" ItemsSource="{Binding Value, Mode=TwoWay}" CellEditEnding="PointDataGrid_CellEditEnding" >
                <DataGrid.AutoGenerateColumns>false</DataGrid.AutoGenerateColumns>
                <DataGrid.CanUserAddRows>true</DataGrid.CanUserAddRows>
                <DataGrid.CanUserDeleteRows>true</DataGrid.CanUserDeleteRows>
                <DataGrid.Columns>
                    <DataGridTextColumn Header="Profile" Binding="{Binding Path=X, Mode=TwoWay, StringFormat='N3'}"  />
                    <DataGridTextColumn Header="Depth" Binding="{Binding Path=Y,Mode=TwoWay, StringFormat='N3'}" />
                </DataGrid.Columns>
            </DataGrid>
        </DataTemplate>
        <DataTemplate x:Key="VectorPathEditor">
            <DataGrid Name="Vector3D_DataGrid" ItemsSource="{Binding Value}" CellEditEnding="PathDataGrid_CellEditEnding">
                <DataGrid.CanUserSortColumns>false</DataGrid.CanUserSortColumns>
                <DataGrid.AutoGenerateColumns>false</DataGrid.AutoGenerateColumns>
                <DataGrid.Columns>
                    <DataGridTextColumn Header="X" Binding="{Binding Path=X, Mode=TwoWay, StringFormat='N3'}"  />
                    <DataGridTextColumn Header="Y" Binding="{Binding Path=Y,Mode=TwoWay, StringFormat='N3'}" />
                    <DataGridTextColumn Header="Z" Binding="{Binding Path=Z,Mode=TwoWay, StringFormat='N3'}" />
                </DataGrid.Columns>
            </DataGrid>
        </DataTemplate>
        <DataTemplate x:Key="CylindricalPathEditor">
            <DataGrid Name="CylindricalDataGrid" ItemsSource="{Binding Value}" CellEditEnding="CylindricalDataGrid_CellEditEnding">
                <DataGrid.CanUserSortColumns>false</DataGrid.CanUserSortColumns>
                <DataGrid.AutoGenerateColumns>false</DataGrid.AutoGenerateColumns>
                <DataGrid.Columns>
                    <DataGridTextColumn Header="R" Binding="{Binding Path=Radius, Mode=TwoWay, StringFormat='N3'}"  />
                    <DataGridTextColumn Header="A" Binding="{Binding Path=Angle,Mode=TwoWay, StringFormat='N3'}" />
                    <DataGridTextColumn Header="D" Binding="{Binding Path=Depth,Mode=TwoWay, StringFormat='N3'}" />
                </DataGrid.Columns>
            </DataGrid>
        </DataTemplate>

The DataGridEditor (needs name change) displays lists of two dimensional points with no problem

The VectorPathEditor shows three dimensional points with no problem. However when I use the class below

public class CylindricalCollection :ObservableCollection<Cylindrical>
{
      
}

the only thing in Property editor display is the Count value, when I set the property grids selected object to a CylindricalCollection object. I am not sure here what is happening so any help would be appreciated.

Thanks

Alan