1

On WP7.5 I created a datacontext like this:

this.DataContext = new { One = listOne, Two = listTwo};

On my XAML code I tried this:

<TextBlock Text="{Binding listOne.m_strTypeTiers}" Style="{StaticResource PhoneTextNormalStyle}" />
<TextBlock Text="{Binding listTwo.m_strTypeTiers}" Style="{StaticResource PhoneTextNormalStyle}" />

My textbox are empty. I think my binding syntax has a mistake.

karel
  • 4,637
  • 41
  • 42
  • 47
Walter Fabio Simoni
  • 5,523
  • 12
  • 51
  • 74

1 Answers1

2

I think you are looking for {Binding One.m_strTypeTiers}

But it depends on what listOne and listTwo are. Are they classes with a property named m_strTypeTiers? If m_strTypeTiers is a field, then you will not be able to databind to it. Databinding only works with properties (by default).


UPDATE
Oops. Silverlight does not support binding to anonymous types. I was thinking of WPF for desktop applications. Windows Phone 7 uses Silverlight which is very similar but different in some important ways. I think you are out of luck - you will need to define a concrete class.

You may find this article helpful in the future:
Contrasting Silverlight and WPF (...not that it would have helped you with this particular question)

Community
  • 1
  • 1
JDB
  • 23,357
  • 5
  • 68
  • 116