加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-13 20:16:02 所属栏目:百科 来源:网络整理
导读:自己在DataGrid行末添加按钮时遇到了这样的问题,设计的时候DataGrid中显示是有按钮存在的,但是一运行按钮就不见了,试验了好几次都是这样子,经过ktei2008老师的指点才知道问题所在,我当时的代码是这样写的: DataGrid.Columns DataGridTextColumn Binding
自己在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>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读