Quantcast
Channel: wpftoolkit Discussions Rss Feed
Viewing all articles
Browse latest Browse all 2157

New Post: Populate Select types combo in CollectionEditor with NewItemTypes

$
0
0
I am having trouble populating the Select Types combo box in the CollectionEditor control.
(Note I refer to CollectionEditor but I beleive this has been renamed CollectionControl)

Here is my xaml:
<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="431" Width="525" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit">
    <Grid>
        <xctk:CollectionControl Height="240"
                                HorizontalAlignment="Left"
                                Margin="12,92,0,0"
                                Name="CollectionControl1"
                                VerticalAlignment="Top"
                                Width="479"
                                >

        </xctk:CollectionControl>
    </Grid>
</Window>
here is code behind:
Class MainWindow

    Public Property PersonCollection As List(Of Person) = New List(Of Person)

    Public Structure Person
        Public Sub New( _
           ByVal _firstname As String,
           ByVal _lastname As String
           )
            structfirstname = _firstname
            structlastname = _lastname
        End Sub
        Property structfirstname As String
        Property structlastname As String
    End Structure

    Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()

        PersonCollection.Add(New Person("sss", "ttt"))
        PersonCollection.Add(New Person("xxx", "yyy"))


        CollectionControl1.ItemsSource = PersonCollection
        CollectionControl1.DataContext = PersonCollection

 
    End Sub

End Class
I think I have to add something like CollectionControl1.NewItemTypes = PersonCollection but this results in a 'unable to cast object of type...' exception.

I know I'm doing something wrong here. Any help would be much appreciated.

Viewing all articles
Browse latest Browse all 2157

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>