微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

CellTemplate不是依赖属性,不能绑定DynamicResource

自己在DataGrid行末添加按钮时遇到了这样的问题,设计的时候DataGrid中显示是有按钮存在的,但是一运行按钮就不见了,试验了好几次都是这样子,经过ktei2008老师的指点才知道问题所在,我当时的代码是这样写的:
                  <DataGrid.Columns>
    			<DataGridTextColumn Binding="{Binding Property1}" Header="Property1"/>
    			<DataGridCheckBoxColumn Binding="{Binding Property2}" Header="Property2"/>
    			<DataGridTemplateColumn Header="功能" CellTemplate="{DynamicResource DataTemplate1}"/>
    		</DataGrid.Columns>


Header为功能的那一列是我要添加的按钮,用的CellTemplate模板,事实上,正如我标题中所写,CellTemplate不是依赖属性,不能绑定DynamicResource,最后的代码是这个样子的:

                  <DataGrid.Columns>
    			<DataGridTextColumn Binding="{Binding Property1}" Header="Property1"/>
    			<DataGridCheckBoxColumn Binding="{Binding Property2}" Header="Property2"/>
    			<DataGridTemplateColumn Header="功能" CellTemplate="{StaticResource DataTemplate1}"/>
    		</DataGrid.Columns>

原文地址:https://www.jb51.cc/javaschema/287077.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐