views:

201

answers:

0

Hi

I have a observable collection as follows....

I used to get designer ignorable error as "type(0) does not support direct content" due to which I implemented ContentProperty as shown below... but now I get two unavoidable errors at the designer as

1.The object 'CustomDataGridColumnCollection' already has a child and cannot add 'DataGridTextColumn'. 'CustomDataGridColumnCollection' can accept only one child. 2. This item represents a default value and cannot be changed.

Please could some one help me here and point out what is wrong?

Thx

Code as below...

<Windows.Markup.ContentProperty("ContentColumns")> _
Public Class CustomDataGridColumnCollection
    Inherits ObservableCollection(Of DataGridColumn)

    Public Property ContentColumns() As IList(Of DataGridColumn)
        Get
            Return Items
        End Get
        Set(ByVal value As IList(Of DataGridColumn))
            For Each item As DataGridColumn In value
                Items.Add(item)
            Next
        End Set
    End Property

End Class

<cc:CustomDataGridColumnCollection x:Key="CustomDataGridColumnCollection">
               <toolkit:DataGridTextColumn Header="Name" Binding="{Binding Path=Name}"></toolkit:DataGridTextColumn>
                <toolkit:DataGridTextColumn Header="Salary" Binding="{Binding Path=Salary}"></toolkit:DataGridTextColumn>
                <toolkit:DataGridTextColumn Header="Designation" Binding="{Binding Path=Designation}"></toolkit:DataGridTextColumn>
</cc:CustomDataGridColumnCollection>