views:

22

answers:

1

Hi guys,

i am a very beginner in WPF. I am trying to create my first app for Windows Phone 7.

I have a Detail View and the .cs class associated to the view.

In my view i have :

  <StackPanel Grid.Row="0" Grid.Column="0">
  <TextBlock Name="textBlock1" Text="..."/>
  </StackPanel>

In the .cs:

  ...
  listAgences = new List<Agence>();

  Agence agence1 = new Agence();
  agence1.Name = "test";
  agence1.Adresse = "test1";
  ...
  listAgences.Add(agence1);
  ...

How do i get to have the Text in the texbox to be "test"? i tried stuff like :

  Text="{Binding Path=listAgences[0].Name}";

in asp.net i know how to do it but here i'm quite lost.

Thx for helping

A: 

Presuming that your datacontext class has a public property List<Agence> ListAgences { get; set; } then binding like that should work, though.

John Gardner
its week end now, i'll try again this way on thursday. i did it from .cs file like : textBlock1=listAgences[0].Name; Though i want to generate the texdBlocks in the interface depending on how many items i have in my list. Right now i have 3 textblocks because my list have 3 hard coded agences. whe i'll use my webservice i won't do that anymore. in mvc.NEt with a template i would do something like that in aspx <%: foreach agence in listAgences { setup UI} %>. i don't know how to do that in xaml
wallou