locked
关于datagrid 操作的问题 RRS feed

  • 问题

  •  

    需要用到datagrid了,感觉silverlight 的datagrid和asp.net里的gridview思路很不一样。

    怎么遍历silverlight datagrid里的每一行数据啊?我想逐行比较某一列的值,符合条件的行做个特殊标记 。看了msdn没看明白,求助求助...

    2008年11月14日 2:08

答案

  • <ListBox>
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <Grid>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition
                                                    Width="150"
                                                />
                                                <ColumnDefinition
                                                    Width="200"
                                                />
                                            </Grid.ColumnDefinitions>
                                            <TextBlock
                                                Text="{Binding C1Name}"
                                                Margin="5"
                                            />
                                            <TextBlock
                                                Grid.Column="1"
                                                Text="{Binding C2Remark}"
                                                Margin="5"
                                            />
                                        </Grid>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>

    2008年11月18日 5:36

全部回复

  • 找到这个了...

    http://forums.microsoft.com/china/ShowPost.aspx?PostID=3507452&SiteID=15

    遇到同样问题的可以到这来看一下

     

    2008年11月14日 2:35
  • <ListBox>
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <Grid>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition
                                                    Width="150"
                                                />
                                                <ColumnDefinition
                                                    Width="200"
                                                />
                                            </Grid.ColumnDefinitions>
                                            <TextBlock
                                                Text="{Binding C1Name}"
                                                Margin="5"
                                            />
                                            <TextBlock
                                                Grid.Column="1"
                                                Text="{Binding C2Remark}"
                                                Margin="5"
                                            />
                                        </Grid>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>

    2008年11月18日 5:36