wpf - How to bind objects list to infragistics data grid? -


Very easy to operate, but the source code does not work as necessary ... please advise.

There is a product collection in the class (the approach is based on the MVVM pattern, but it does not grow on the current issue):

  public class ProductWindowViewModel: Workspace ViewModel // Applied InotifyPropertyChanged {public ProductWindowViewModel () {product = new list & lt; Products & gt; (ProductService.Instance.Repository.GetAll ()); } List & lt; Products & gt; Product {Received; Set; }}  

Here is the class declaration:

  Public category products: IERTTI {#region Public Properties Public Entry ID (Receive); Set; } Public string name {get; Set; } Public string description {get; Set; } Public int cost {get; Set; } #endregion}  

The class example window is linked to the grid data reference:

  ProductWindow wnd = new ProductWindow (); Wnd.MainGrid.DataContext = New ProductWindowViewModel (); Wnd.ShowDialog ();  

And here is the xaml code of the window:

  & lt; Window x: orbit = "WpfTest1.ProductWindow" xmlns = "http: // schema .microsoft.com/fonfx/ 2006/xaml/presentation" xmlns: x = "http://schemas.microsoft.com/winfx/2006/ Xaml "title =" product window "height =" 300 "width =" 300 "xmlns: IgDP =" http://infragistics.com/DataPresenter "xmlns: see modell =" clr- namespace: see modell; assembly = see modell "& gt; & Lt; Grid X: Name = "Main Grid" & gt; & Lt; Grid.Resources & gt; & Lt; ObjectDataProvider x: key = "odpObjectDataProvider" object type = "{x: model view: ProductWindowViewModel}" /> & Lt; /Grid.Resources> & Lt; Grid Datacentext = "{Static RSOROD ObjectDet Provider}" & gt; & Lt; IgDP: XamDataGrid DataSource = "{Binding Path = Product}" /> & Lt; / Grid & gt; & Lt; / Grid & gt;  

xamDataGrid sampe is similar to the overall code is very simple but does not work.

Does anyone know why?

Thank you.

OK, maybe this will not answer your question at all, but it seems that you can see your view -Model is inventing the class twice. Once in your code, immediately after you make your window, and once in the ObjectDataProvider thing, if you are organized on one of these, it might be easy to debug. Suggestions:
1. View this line: wnd.MainGrid.DataContext = New ProductWindowViewModel ();
2. Set up a breakpoint inside your Voododal constructor 3. Start it and see whether breakpoint has been hit or not. If this hits, then you know that you are doing something right.

Also check the output window in Visual Studio and see if any binding exceptions have been reported.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -