Datagrid有多个bug;
1,不支持DynamicResource的东西
2, 在Column隐藏后再显示, ColumnHeader的Tag或者DataContext为null。
解决办法:
用StaticResource ,如下面的 StaticResource DGC_ContentTemplate;
用DataGridColumnHeader的Column,来取得上层的datacontext。如, ItemsSource="{Binding Path=Column.Tag, Converter ={StaticResource DebugConverter}, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x: Type DataGridColumnHeader}}}"
private void InitDataGridBinding (DataGridColumnEx col, string path)
{
if (null == col || String.IsNullOrWhiteSpace (path) || null == col .Header)
{
return;
}
Binding binding = new Binding();
binding.Mode = BindingMode. OneWay;
binding.RelativeSource = new RelativeSource(RelativeSourceMode .Self);
binding.Converter = new BoolToVisibilityConverter();
binding.Path = new PropertyPath("(FrameworkElement.DataContext).PACfgVM." + path + ".CfgInfo[" + PAAttachedProperty. GetName(col ) + "].IsVisiable");
BindingOperations.SetBinding (col, DataGridColumnEx.VisibilityProperty , binding);
//{for combobox binding in columnHeader
col.Tag = PAAttachedProperty. GetTag(col );
DependencyPropertyDescriptor dpd = DependencyPropertyDescriptor .FromProperty( DataGridColumnEx.VisibilityProperty , typeof(DataGridColumnEx ));
if (dpd != null)
{
dpd.AddValueChanged (col, delegate
{
//
InitDataGridColumnHeader(col , GetDataGridParent( col));
});
}
//}
}
<DataTemplate x :Key="DGC_ContentTemplate">
<TextBlock TextWrapping ="Wrap" Text="{ Binding }" MinWidth ="20"/>
</DataTemplate>
<Style x:Key ="DataGridColumnHeaderStyle_ComboBox" TargetType="{x :Type DataGridColumnHeader}">
<Setter Property ="ContentTemplate" Value="{ StaticResource DGC_ContentTemplate}"/>
<Setter Property ="VerticalContentAlignment" Value="Center"/>
<Setter Property ="Template">
<Setter.Value>
<ControlTemplate TargetType ="{x: Type DataGridColumnHeader}">
<Grid>
<StackPanel Orientation ="Vertical" d:LayoutOverrides="Height" Margin="10">
<Label Foreground ="Black" HorizontalContentAlignment="Left" Content="{TemplateBinding Content }"/>
<!--<ComboBox Margin="0,10,0,0" ItemsSource="{Binding (FrameworkElement.Column.).TimeSearchGroup, Converter={StaticResource DebugConverter}, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}}"/>-->
<!--<ComboBox Margin="0,10,0,0"
ItemsSource="{Binding Path=Tag, Converter={StaticResource DebugConverter}, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGridColumnHeader}}}"></ComboBox>-->
<ComboBox Margin ="0,10,0,0"
ItemsSource="{Binding Path=Column.Tag, Converter ={StaticResource DebugConverter}, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x: Type DataGridColumnHeader}}}"></ ComboBox>
</StackPanel>
<Thumb x :Name="PART_LeftHeaderGripper" HorizontalAlignment="Left" Style="{StaticResource ColumnHeaderGripperStyle}"/>
<Thumb x :Name="PART_RightHeaderGripper" HorizontalAlignment="Right" Style="{StaticResource ColumnHeaderGripperStyle}"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<EventSetter Event ="Selector.SelectionChanged" Handler="ComboBox_SelectionChanged"/>
</Style>
- Tomcat一个BUG造成CLOSE_WAIT
之前应该提过,我们线上架构整体重新架设了,应用层面使用的是Spring Boot,前段日子因为一些第三方的原因,略有些匆忙的提前开始线上的内测了.然后运维发现了个问题,服务器的HTTPS端口有大量的C ...
- a标签点击跳转失效--IE6、7的奇葩bug
一般运用a标签包含img去实现点击图片跳转的功能,这是前端经常要用到的东西. 今天遇到个神奇的bug:如果在img上再包裹一层div,而且div设置了width和height,则图片区域点击时,无任何 ...
- 关于 Chrome 浏览器中 onresize 事件的 Bug
我在写插件时用到了 onresize 事件,在反复地测试后发现该事件在 Chrome 及 Opera(内核基本与 Chrome 相同,以下统称 Chrome)浏览器打开时就会执行,这种情况也许不能算作 ...
- Chrome出了个小bug:论如何在Chrome下劫持原生只读对象
Chrome出了个小bug:论如何在Chrome下劫持原生只读对象 概述 众所周知,虽然JavaScript是个很灵活的语言,浏览器里很多原生的方法都可以随意覆盖或者重写,比如alert.但是为了保证 ...
- 一个粗心的Bug,JSON格式不规范导致AJAX错误
一.事件回放 今天工作时碰到了一个奇怪的问题,这个问题很早很早以前也碰到过,不过没想到过这么久了竟然又栽在这里. 当时正在联调一个项目,由于后端没有提供数据接口,于是我直接本地建立了一个 json ...
- 了不起的 nodejs-TwitterWeb 案例 bug 解决
了不起的nodejs算是一本不错的入门书,不过书中个别案例存在bug,按照书中源码无法做出和书中相同效果,原本兴奋的心情掺杂着些许失落. 现在我们看一下第七章HTTP,一个Twitter Web客户端 ...
- 应该是Angular2的一个bug?
为了应对未来的趋势,及时赶上下一趟互联网技术,我最近也在通过具体项目研究angular2,首先必须要吐槽的是,学习angular2的成本本身不高,但是一堆的工具.配置实在让人 很是焦灼,就像asp.n ...
- 记录一次bug解决过程:数据迁移
一 总结 不擅长语言表达,勤于沟通,多锻炼 调试MyBatis中SQL语法:foreach 问题:缺少关键字VALUES.很遗憾:它的错误报的让人找不着北. 二 BUG描述:MyBatis中批量插入数 ...
- 关于MJRefresh的下拉加载数据bug
当没有更多数据的时候显示NoMoreData 我的理解是先结束刷新再显示没有更多 今天之前一直没发现有问题 贴之前的代码 [self.collectionView reloadData]; [self ...
随机推荐
- mysql中把空值放在最后,有值的数据放在前面
order by column is null,column; 如果:order by column,则column中空值的数据放在最前面,有数据的放在后面
- jdk并发工具包之锁
1.cynchronized扩展:可重锁入ReentrantLock ReentrantLock是通过cas算法实现的 RenntrantLock lock=new ReentrantLock(); ...
- Linux U盘只读解决方法
Linux Fat的U盘只读,这个问题经常出现,原因大家都说了是U盘的错误,出现这种情况后,一般的解决方案是 mount | grep <U盘的标签> # 找到你的U盘的对应的设备名称,如 ...
- centOS7 安装nginx+php+mysql
nginx安装 本文是介绍使用源码编译安装,包括具体的编译参数信息. 正式开始前,编译环境gcc g++ 开发库之类的需要提前装好. 安装make: yum -y install gcc automa ...
- 使用Reveal来查看别人的APP界面+白苹果不刷机解决方式
Reveal这个强大的界面调试工具.能够实时查看.改动view的属性,大体上实现了iOS程序猿梦寐以求的功能.比方,有时候我们加入了一个view,可是那个view死活不显示出来,这时候祭出Reveal ...
- java timer 指定某时间点执行
package com.northeasttycoon.service; import java.util.Calendar;import java.util.Timer;import java.ut ...
- python 基础 3.2 文件 for 练习
#/usr/bin/python #coding=utf-8 #@Time :2017/11/1 22:19 #@Auther :liuzhenchuan #@File :1030-1031练 ...
- 常见 WEB 安全漏洞(转)
SQL注入 成因:程序未对用户的输入的内容进行过滤,从而直接代入数据库查询,所以导致了sql 注入 漏洞 . 思路:在URL处可以通过 单引号 和 and 1=1 and 1=2 等语句进行手工测试s ...
- 破解powerdesigner教程
点Tool
- HDU - 3068 最长回文 【Manacher】
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=3068 思路 n^3 的做法 对于每个字符 同时 往左往右搜 但是要分奇偶 就是 n^3 n^2 的做法 ...