View Single Post
Old 05-29-2007   #3 (permalink)
Radek Cerny


 
 

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 SpecsSystem Spec