开发者

Silverlight datapager not firing load events

开发者 https://www.devze.com 2023-03-05 16:40 出处:网络
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 data

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="l开发者_如何学GoblUser_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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消