Print Page | Close Window

DevForce EF and WPF

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1034
Printed Date: 31-Mar-2025 at 8:47pm


Topic: DevForce EF and WPF
Posted By: Amy
Subject: DevForce EF and WPF
Date Posted: 23-Dec-2008 at 8:39pm
Hi there,
 
I am trying theDevForce EF and WPF. The ListBox Control of WPF needs to bind to a collection.  Does DevFoce EF help me to generate the collections? For example, I have table called OrderType and want to show everything in that table, the DevForce EF will generate OrderType class for me, but I can't bind it to the Listbox since it is not a collection. Do I have to get the collection on my own? Is any simple way to do it? Any WPF example with DevForce EF would be helpful.
 
Thanks in advance!
 
Amy



Replies:
Posted By: GregD
Date Posted: 24-Dec-2008 at 6:18pm
Originally posted by Amy

Hi there,
 
I am trying theDevForce EF and WPF. The ListBox Control of WPF needs to bind to a collection.  Does DevFoce EF help me to generate the collections? For example, I have table called OrderType and want to show everything in that table, the DevForce EF will generate OrderType class for me, but I can't bind it to the Listbox since it is not a collection. Do I have to get the collection on my own? Is any simple way to do it? Any WPF example with DevForce EF would be helpful.
 
Thanks in advance!
 
Amy
 
 
A LINQ query against a DevForce EF EntityManager can be passed directly into the constructor of pretty much any list type.  Generally speaking, you should use a .NET ObservableCollection<T> if you going to do WPF data binding against the list:

   ObservableCollection<Employee> emps = new ObservableCollection < Employee >(_mgr.Employees);

If you're going to do Winform data binding, use a DevForce IdeaBlade.Util.BindableList<T>:
 
   BindableList<Employee> emps = new BindableList< Employee >(_mgr.Employees);
 
For non-data-binding uses, you can use the lighter-weight List<T>
 
   List<Employee> emps = new List< Employee >(_mgr.Employees);
 
 



Print Page | Close Window