zoukankan      html  css  js  c++  java
  • Bug:DataGridCell的显示不完整

    最近在使用DataGrid时遇到一个bug, 在客户机器上DataGrid的内容显示不完整, 具体表现为某些列的显示为空。

    具体的可视树为:DataGridCell > ContentPresenter > TextBlock。其中:TextBlock的Width为Auto, HorizontalAlignment为Stretch;ContentPresenter的With为Auto,HorizontalAlignment为Left。

    用snoop调查的结果是,在显示正常的机器上ContentPresenter的Width为TextBlock的ActualWidth,在显示错误的机器上ContentPresenter的Width为0.很明显,因为ContentPresenter的宽度太小导致文字看不见而不是TextBlock没有显示文字。

    解决办法:设置ContentPresenter的HorizontalAlignment为Stretch。

    遗留问题:为什么同样的HorizontalAlignment在有些机器上Width会为0,而客户机器上为正常宽度呢?
    我猜测是机器性能配置低,数据库的数据获取耗时,导致UI渲染时数据并没有完全获取成功,因此DataGridCell刚开始的Width即为0, 而当数据获取成功后TextBlock的渲染正常,而此时的CellTemplate内容更新并没有导致Cell的ContentPresenter宽度更新。
  • 相关阅读:
    spring对java远程调用的简化(二)之Hessian,Burlap
    Get busy living--or get busy dying
    Spring:Bean基本管理
    不工作的日子
    Get busy living--or get busy dying
    Spring:Bean基本管理
    不工作的日子
    LAMP2 Apache安装
    apache httpclient 使用
    mysql随机取表中一条数据
  • 原文地址:https://www.cnblogs.com/muzizongheng/p/3517392.html
Copyright © 2011-2022 走看看