![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| Guest | Manual population of listview Hi, pulling out whats left of my hair... Assuming I have a simple xaml file with a listview, or even some other placeholder, does anyone have simple code to demonstrate manual (eg cell by cell, row by row) population of a listview? I can certainly programmatically create all I need including GridViewColumn headers and ListViewItem objects, BUT ListViewItem exposes only a simple Content property of type object, and I can not figure out how to provide the cell information to correspond with the column/header definitions. Can anyone help please!? |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: Manual population of listview Normally you specify the content of the ListView by setting the ItemSource property of the Items property. You can see good examples of that here: http://msdn2.microsoft.com/en-us/lib....listview.aspx http://blogs.msdn.com/atc_avalon_tea...23/537715.aspx Alternatively you can add row by row, a brief step by step here: 1. Assuming you have a custom class (Employee) that exposes properties for FirstName and LastName. 2. Add two GridView columns. 3. On the first one set col1.DisplayMemberBinding = new Binding("FirstName"); 4. On the second one set col2.DisplayMemberBinding = new Binding("LastName"); 5. Create an instance of your custom object, like: Employee emp = new Employee(); emp.FirstName = "Joe"; emp.LastName = "Doe"; // Next add to the ListView MyListView.Items.Add(emp); That should do it. HTH, Plamen Ratchev http://www.SQLStudio.com |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: Manual population of listview Hi, thanks for that. I am glad someone is listening. My problem is one of abstraction and UI - Business Object separation. I have a sever that exposes only Web Services, and behind that of course is a wonderful world of Business Objects, ORM, etc. Now on the client I have WPF - the Presentation Layer. I need to be able to handle very dynamic data on the client; the Business Objects do not exist client side - only the data. The WebService may publish an XML document that carries data+metadata (eg column Names/types/widths etc). I need to respond to the metadata by dynamically creating columns in the GridView, and publishing the data as well. All formatting, business rule execution etc happens on the server. The client only has a remote URL to talk to, and is very very "thin". I have managed to get a XmlDataProvider working, but now I am having trouble with Templates; is there a programmatic way of creating a DataTemplate with dynamic binding? Cheers, and thanks again, Radek "Plamen Ratchev" <Plamen@SQLStudio.com> wrote in message news:Odn04BgoHHA.4512@TK2MSFTNGP03.phx.gbl... > Normally you specify the content of the ListView by setting the ItemSource > property of the Items property. You can see good examples of that here: > http://msdn2.microsoft.com/en-us/lib....listview.aspx > http://blogs.msdn.com/atc_avalon_tea...23/537715.aspx > > Alternatively you can add row by row, a brief step by step here: > > 1. Assuming you have a custom class (Employee) that exposes properties for > FirstName and LastName. > 2. Add two GridView columns. > 3. On the first one set col1.DisplayMemberBinding = new > Binding("FirstName"); > 4. On the second one set col2.DisplayMemberBinding = new > Binding("LastName"); > 5. Create an instance of your custom object, like: > Employee emp = new Employee(); > emp.FirstName = "Joe"; > emp.LastName = "Doe"; > // Next add to the ListView > MyListView.Items.Add(emp); > > That should do it. > > HTH, > > Plamen Ratchev > http://www.SQLStudio.com > > > |
My System Specs![]() |
| | #4 (permalink) |
| Guest | Re: Manual population of listview You can programmatically use the DataTemplate class. First you have to create the VisualTree of elements for the template and then you can dynamically bind your XML data. Here are two examples, I believe the combination of both will give you all necessary to understand and implement the concept: http://dedjo.blogspot.com/2007/03/cr...from-code.html http://blogs.microsoft.co.il/blogs/t...detection.aspx HTH, Plamen Ratchev http://www.SQLStudio.com |
My System Specs![]() |
| | #5 (permalink) |
| Guest | Re: Manual population of listview Hi Plamen, I've had a quick look at the links and they look very promising... will keep you posted. Cheers, Radek "Plamen Ratchev" <Plamen@SQLStudio.com> wrote in message news:u%23MomDmoHHA.3460@TK2MSFTNGP04.phx.gbl... > You can programmatically use the DataTemplate class. First you have to > create the VisualTree of elements for the template and then you can > dynamically bind your XML data. > > Here are two examples, I believe the combination of both will give you all > necessary to understand and implement the concept: > http://dedjo.blogspot.com/2007/03/cr...from-code.html > http://blogs.microsoft.co.il/blogs/t...detection.aspx > > HTH, > > Plamen Ratchev > http://www.SQLStudio.com > > > |
My System Specs![]() |