Search code examples
silverlighteventsdatagriddatapager

Silverlight datapager not firing load events


Here's my problem:

I have a datagrid that is bound to a collection of objects. One column only contains an ID and I need to turn this ID into the user's name that is associated with it. In the datagrid, I have a template column that contains a textblock. That textblock has a loaded event which will then take the ID, look up the user, and set the textblock text to the user's name.

<sdk:DataGridTemplateColumn Width="Auto" Header="User">
   <sdk:DataGridTemplateColumn.CellTemplate  >
      <DataTemplate>
         <TextBlock Name="lblUser" Height="25" Margin="10"  Loaded="lblUser_Loaded" />
      </DataTemplate>
   </sdk:DataGridTemplateColumn.CellTemplate>
 </sdk:DataGridTemplateColumn>

Everything works without a datapager, but as soon as I add one it only fires the loaded event for the first page. Every page after that will just contain the results of the first page. How do I get this to work. Am I even on the right track with any of this? Is there a better way to lookup IDs in a datagrid?


Solution

  • No you are not on the right track with this. The Loaded event will only fire once. Why can you not just use binding and change the bound data objects to include the full user name? Get your data objects right rather than making a lot of work for yourself.