【问题标题】:Resizing Cell Height of Silverlight datagrid row?调整 Silverlight 数据网格行的单元格高度?
【发布时间】:2011-02-10 17:29:29
【问题描述】:

我能够弄清楚如何使用鼠标扩展和收缩一列数据网格。但是在收缩和扩展一列之后,单元格的高度并没有降低。

如何获得单元格(或行)的原始高度? 你能调查一下吗?

谢谢 阿杰

【问题讨论】:

  • AJ,你找到解决办法了吗?

标签: c# silverlight datagrid resize


【解决方案1】:

由于我无法在 SO 上找到此解决方案,我将在此处输入我的解决方案。

您需要找到导致您的行大小错误的事件。就我而言,它只是向上和向下滚动(但我已经在几种不同类型的事件中看到了这一点)。这是让你的数据网格调整大小的代码:

    /// <summary>
    /// Reset datagrid row height
    /// </summary>
    /// <param name="row"></param>
    public void ResetRowHeight(DataGrid grid, DataGridRow row)
    {
        // only for autosize rows
        if (!double.IsNaN(row.Height)) return;

        // store current rowheight
        double rowheight = grid.RowHeight;

        // fore recalculating row height
        grid.RowHeight = 0;
        row.UpdateLayout();

        // restore rowheight
        grid.RowHeight = rowheight;
        row.UpdateLayout();
    }

grid 是你的数据网格,row 是需要重置的行。

现在只需找到导致您的问题的事件,应该就是它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-02
    • 1970-01-01
    • 1970-01-01
    • 2018-09-04
    相关资源
    最近更新 更多