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 ...
随机推荐
- IPv4地址(一)概述
IPv4地址的长度是多少? IPv4地址是如何表示的? IPv4地址的构成以及每一部分所起到的作用和占的位数特点? IPv4地址长度为32位. IPv4地址分为两部分:网络号和主机号 网络号部分惟一地 ...
- 使用T4模板为EF框架添加数据库实体注释
网上有一个解决方法如下: http://www.cnblogs.com/stone_w/archive/2012/10/25/2738345.html 不过我试了下没解决太麻烦了 而且一旦EF要重新生 ...
- iOS开发 viewWillAppear:(BOOL)animated真机调试的时候不执行了怎么办
本文转载至http://blog.sina.com.cn/s/blog_a843a8850101e0g7.html 现在需要的.h文件里面加上. 然后,在需要的.m文件按里面加上关键代码:self ...
- 九度OJ 1055:数组逆置 (基础题)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:7324 解决:3429 题目描述: 输入一个字符串,长度小于等于200,然后将数组逆置输出. 输入: 测试数据有多组,每组输入一个字符串. ...
- go colly proxy 代理ip 动态 ip
package main import ( "fmt" "github.com/gocolly/colly" "github.com/gocolly/ ...
- java 对象变量 c++对象指针 初始化对象变量的2中方法
java 对象变量 c++对象指针 java null引用 c++ null指针 Date deadline 是 对象变量,它可以引用Date类型的对象,但它不是一个对象,实际上它也没有引用对象. ...
- typescript import 全局node_modules报错
项目里面有一个node_modules的包太大,每次放到docker里面都要下载半天,大大减少了部署效率. 所以考虑将这个node包全局安装到docker的基础镜像中,那么代码里面直接引用全局包就可以 ...
- 使用 eslint 和 editorconfig 规范代码
项目中使用eslint 为什么使用eslint : 为了保持代码风格的统一 在做vue项目的时候, 基本上都会使用 vue-cli 脚手架去创建一个vue 项目,里面可以选择使用eslint 代码检测 ...
- JAVA线程sleep和wait方法区别 代码
package test; import java.util.Date; import java.util.Random; public class test { public static void ...
- Windows、Linux、Mac OSX编译jni动态库
在不同平台下默认调用不同名字的动态库,在Windows平台调用name.dll,在Linux平台调用libname.so,在OSX下调用libname.jnilib.不同平台下的编译的方法也有些区别. ...