.net – DataTemplate中的TemplateBinding不起作用
发布时间:2020-12-14 05:38:54 所属栏目:Windows 来源:网络整理
导读:我正在通用 Windows应用程序中创建模板化控件. 问题在于 Button Content =“{Binding}”Command =“{TemplateBinding AddCharCommand}”/ TemplateBinding不起作用. 似乎问题是因为它是在DataTemplate中定义的. 这是样式和应用于我的控件的模板. Style Targe
我正在通用
Windows应用程序中创建模板化控件.
问题在于< Button Content =“{Binding}”Command =“{TemplateBinding AddCharCommand}”/> TemplateBinding不起作用. 似乎问题是因为它是在DataTemplate中定义的. 这是样式和应用于我的控件的模板. <Style TargetType="local:CoordinatesControl"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="local:CoordinatesControl"> <ListView ItemsSource="{TemplateBinding Numbers}"> <ListView.ItemTemplate> <DataTemplate> <Button Content="{Binding}" Command="{TemplateBinding AddCharCommand}" /> </DataTemplate> </ListView.ItemTemplate> </ListView> </ControlTemplate> </Setter.Value> </Setter> </Style> 解决方法
您不能在DataTemplate中使用TemplateBinding,但有一些解决方法:
>您可以使用所需的DataContext为某些隐藏元素创建一种代理.更多细节here. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- win7/10下Qt Creator调试提示:The selected debugger may
- windows-phone-7 – 在WP7上的isolatedStorage中存储一个大
- windows-server-2012 – 根据IP限制对RD网关的访问
- windows-server-2008 – 是否可以逐步从工作组迁移到域?
- windows – 如何对Inno Setup生成的卸载文件进行数字签名?
- windows-7 – Windows 7上的OpenVPN客户端,数据包未路由
- Windows 2008:虚拟文件系统(如FUSE)
- windows – 如何在推送设置中进行正确的错误处理?
- 文档生成 – 如何获取Microsoft HTML帮助2编译器?
- Expand命令行详解
推荐文章
站长推荐
- Windows 7上的内联函数的doParallel问题(适用于L
- 如何强制执行Office 365自定义“角色分配策略”默
- windows – 如何监控员工的计算机活动?
- 在Windows Sever2016中搭建DHCP服务为客户机提供
- Windows 7或Server 2008显示进程的运行时间
- New-Object上的Windows RT Powershell(Permissio
- 测量Windows中设备驱动程序的内存使用情况
- windows-server-2003 – Windows域控制器是否向通
- windows – 应用计算机设置期间发生了什么
- 如何在Windows 2012 RDP中禁用TLS 1.0
热点阅读