如何为每个Silverlight Datagrid识别Label控件

时间:2013-08-02 04:03:20

标签: datagrid silverlight-4.0

如何在foreach Silverlight Datagrid中识别标签控件

对于TaskDataGrid.ItemsSource

中的每个项目

TryCast(TryCast(item,StackPanel).Children(2),Label).Content =“New Text”

下一步

我在第二列中有标签控制如何识别和分配值

1 个答案:

答案 0 :(得分:0)

这很好..

For Each rowItem In TaskDataGrid.ItemsSource 
            ' Ensures that all rows are loaded. 
            TaskDataGrid.ScrollIntoView(rowItem, TaskDataGrid.Columns.Last())  
            Dim fe As FrameworkElement = TaskDataGrid.Columns(2).GetCellContent(rowItem)
            Dim fe1 As FrameworkElement = TaskDataGrid.Columns(1).GetCellContent(rowItem)

            Dim gridCmbo As Grid = DirectCast(fe, Grid)

            Dim gridCmbo1 As Grid = DirectCast(fe1, Grid)

            Dim lbltaskId As Label = CType(gridCmbo1.FindName("lbltaskId"), Label)

            Dim lblBaseReceipt As Label = CType(gridCmbo.FindName("lblBaseReceipt"), Label)


        Next