Click here to Skip to main content
13,055,047 members (61,621 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I'm unable to Create CollectionViewSource with the Collection,I have an XML file and Deserilized it to get Collection,
XML File

<?xml version="1.0" encoding="utf-8" ?>
<Stack Id="001" Name="KEYABLE">
  <Pages PageName="Stack1">
    <Page PT="ENVELOPE" >
        <File FN="C:\Work\002885118s51128444038\PageCode\X11090_0009_001\X11090_0009_001_001.tif" FF="TIFF" Index="1"/>
    <Page PT="UNKNOWN">
        <File FN="C:\Work\002885118s51128444038\PageCode\X11090_0009_001\X11090_0009_001_001.tif" FF="TIFF" Index="2"/>
<Stack Id="002" Name="KEYABLE">
  <Pages PageName="Stack2">
    <Page PT="ENVELOPE">
        <File FN="C:\Work\002885118s51128444038\PageCode\X11090_0009_001\X11090_0009_001_003.tif" FF="TIFF" Index="1"/>
    <Page PT="UNKNOWN">
        <File FN="C:\Work\00288511851128436351\N12208_0000_020\00000059.tif" FF="TIFF" Index="2"/>

and i set DataContext to my Usercontrol with the Deserilized Collection,DataContext has been set perfectly.

Public Sub New()
            Dim Reader As New Xml.XmlTextReader("F:\WPFSample Apps\TabControl--DynamicTab\WPFDyanamicTab_vb\XMLFile.xml")
            Dim oStack As New Stacks
            oStack = Sympraxis.Capture.Common.XObjectBase.OpenXml(Reader, oStack.GetType)
            Me.DataContext = oStack
    Dim myCollectionView As ListCollectionView
            myCollectionView = CType(CollectionViewSource.GetDefaultView(Me.DataContext), ListCollectionView)
        End Sub

when i assign it to myCollectionView ,i'm getting "Nothing" in MycollectionView,
This is a collection contains List of Collections.
when i worked with simple collection its working perfect,but this is not happening in my case,how can i achieve it?
Posted 27-Jun-13 2:16am
Updated 27-Jun-13 2:28am
Pheonyx 27-Jun-13 8:28am
Are you getting any exceptions being thrown?
If so what does the exception say?
Pheonyx 27-Jun-13 8:42am
If you step through the code, do you get a valid response if you put :
CollectionViewSource.GetDefaultView(Me.DataContext) in a watch window?
kumar.selva.c 28-Jun-13 2:17am
Actually when i set oStack to Me.datacontext its perfect, But when i set it to myCollectionView = CType(CollectionViewSource.GetDefaultView(Me.DataContext), ListCollectionView), i'm getting mycollectionView = Nothing

and exception has not been thrown.
Pheonyx 28-Jun-13 2:56am
My point was more, what happens if you don't do the casting just the CollectionViewSource.GetDefaultView(Me.DataContext) bit.
kumar.selva.c 28-Jun-13 3:23am
@Pheonyx, Its also not working , but when i do like this
myCollectionView = CType(CollectionViewSource.GetDefaultView(DirectCast(DataContext, ThumbnailImages_Test.Stacks).Stacks), ListCollectionView)

i'm able to get mycollectionview but still, since this is multiple collection i'm unable to group and sort.
If it is a single collection, CollectionViewSorurce works perfectly, i don how to deal with list of Collection , if you see the above XML file there are two stack collection which in turn cointains many collection,

i want to group by "PT" and Filter by Index which is inside the File Collection and to load images in Filename,

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 27 Jun 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100