Click here to Skip to main content
15,883,336 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone,

I am trying to learn ObjectDataProvider but now I am stuck!
This is what I am trying to do:
Classes :
Class MyIntIsHere
 Dim a As Integer

 Public Property myA() as Integer
     Return a
  End Get
  Set(ByVal value as String)
  End Set
 End Property

 Public Sub New(_a as Integer)
 End sub

End Class

Class DisplayIt
 Private lst As New List(of MyIntIsHere)

 Public Sub New()

 End Sub

 Public Function ShowIt() as List(of MyIntIsHere)
  lst.Add(new MyIntIsHere(1))
  return lst
 End Function

End Class

 <ObjectDataProvider x:key="MyProvider" ObjectType="{x:Type local:DisplayIt}" MethodName="ShowIt"/>
Now i want to display it in a ListBox :
<ListBox ItemsSource="{Binding Source={StaticResource MyProvider}}" and other things >
  <TextBlock Text="{Binding Path=myA}"/>

But it doesn't display the integer 'a' of class MyIntIsHere.

What am I missing?
Updated 8-Nov-10 2:01am
Sandeep Mewara 25-Oct-10 9:20am    
Use PRE tags to format your code part. It makes the question readable.
Tarun.K.S 25-Oct-10 9:22am    
thanx Sandeep. Will do it next time.

1 solution

I have solved this by myself!
I read a couple of books but ObjectDataProvider was not properly covered, so had to do some more "Googling" and learnt more about it.
Now i have understood it very well!
So i didn't change much in the question but did some changes to the DisplayIt class and its function ShowIt().
So the answer now lies in the question itself!
Now it works smoothly! :)
Share this answer

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