Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
I'm unable to Create CollectionViewSource with the Collection,I have an XML file and Deserilized it to get Collection,

XML File

XML
<?xml version="1.0" encoding="utf-8" ?>
<Stacks>

<Stack Id="001" Name="KEYABLE">
  <Pages PageName="Stack1">
    <Page PT="ENVELOPE" >
      <Files>
        <File FN="C:\Work\002885118s51128444038\PageCode\X11090_0009_001\X11090_0009_001_001.tif" FF="TIFF" Index="1"/>
      </Files>
    </Page>
    <Page PT="UNKNOWN">
      <Files>
        <File FN="C:\Work\002885118s51128444038\PageCode\X11090_0009_001\X11090_0009_001_001.tif" FF="TIFF" Index="2"/>
      </Files>
    </Page>
        </Pages>
</Stack>

<Stack Id="002" Name="KEYABLE">
  <Pages PageName="Stack2">
    <Page PT="ENVELOPE">
      <Files>
        <File FN="C:\Work\002885118s51128444038\PageCode\X11090_0009_001\X11090_0009_001_003.tif" FF="TIFF" Index="1"/>
      </Files>
    </Page>
    <Page PT="UNKNOWN">
      <Files>
        <File FN="C:\Work\00288511851128436351\N12208_0000_020\00000059.tif" FF="TIFF" Index="2"/>
      </Files>
    </Page>
     </Pages>
  </Stack>

</Stacks>


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

VB
Public Sub New()
            InitializeComponent()
            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,
Quote:
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
Updated 27-Jun-13 2:28am
v2
Comments
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900