【问题标题】:How to manipulate à DataGrid in Silverlight 3如何在 Silverlight 3 中操作 à DataGrid
【发布时间】:2010-04-19 10:23:10
【问题描述】:

我无法在 Silverlight Grids 中操作 Cell 内容... 我可以得到我的 DataGrid,Columns 但不是 Cell 值。

如何获得每行的第一个单元格,它是按钮中的图像? 我只能通过 button_click 之类的事件来实现我的目标,而不是在后面的常规代码中。

感谢帮助

【问题讨论】:

    标签: c# .net silverlight silverlight-3.0


    【解决方案1】:

    您可以使用DataGrid.SelectedItem 属性并将记录转换为您想要的对象。

    Customer c = GrdCustomers.SelectedItem as Customer;
    if (c != null)
    {
        string customerId = c.CustomerID;
    }
    

    假设您的数据源为客户。

    【讨论】:

    • @Polo:感谢您的指出。我已经更新了我的回复,如果这没有帮助,请告诉我。
    • DataGrid.SelectedItem 已经在我的项目中转换为 XmlProduct,这不是问题。假设 Product.ID == 1 我想在我的网格中获取不同的行来更改 Columns[0].Cell[0].Content 中的小图片。我该怎么做?
    猜你喜欢
    • 2011-01-03
    • 2010-12-22
    • 1970-01-01
    • 2011-02-06
    • 2010-11-09
    • 2011-01-15
    • 2011-01-10
    • 2014-12-29
    • 2011-01-02
    相关资源
    最近更新 更多