Many data types in single column

Apr 8, 2009 at 8:43 PM
Hi

I want to create something similar to Properties Editor (like e.g. in Visial studio), where in second column (titled 'values') I can host many types (like text editor, drop down, color picker, etc)

Is is possible to handle it, with both "normal " and edit cell template.

I have created something like:

        <DataTemplate DataType="{x:Type Properties:DropDownProperty}">
            <ComboBox Grid.Column="1" ItemsSource="{Binding Path=Items}" DisplayMemberPath="Title"
                    SelectedValue="{Binding Path=SelectedItem}" />
        </DataTemplate>
        <DataTemplate DataType="{x:Type Properties:TextProperty}">
                           ...
        </DataTemplate>

<Toolkit:DataGrid  AutoGenerateColumns="False" ItemsSource="{Binding Path=SelectedControl.Properties}">
        <Toolkit:DataGrid.Columns>            
            <Toolkit:DataGridTextColumn Binding="{Binding Name, Mode=OneWay}" Header="Name" IsReadOnly="True" />
            <Toolkit:DataGridTemplateColumn Header="Value">
                <Toolkit:DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <ContentControl Content="{Binding}" />
                    </DataTemplate>
                </Toolkit:DataGridTemplateColumn.CellTemplate>
            </Toolkit:DataGridTemplateColumn>
        </Toolkit:DataGrid.Columns>
    </Toolkit:DataGrid>

But with this approach, I cannot switch EditCellTemplate<->CellTemplate, since DataTemplate for cutom type is defined globally.

Is there any way to solve this problem?

Mirek