gpt4 book ai didi

c# - 我怎么能{x :Bind} to a DataTemplate's root type in UWP?

转载 作者:太空狗 更新时间:2023-10-29 17:44:32 26 4
gpt4 key购买 nike

我有一个接收 string 作为其数据类型的模板:

<DataTemplate x:DataType="System:String">
<TextBlock Text="{x:Bind}" />
</DataTemplate>

但是这种绑定(bind)技术给我带来了构建错误。如何在没有路径值的情况下使用 {x:Bind}?我想绑定(bind)字符串,而不是字符串中的属性。

最佳答案

您实际上可以在不指定路径的情况下执行Text="{x:Bind}"设计师会提示,但忽略它是安全的。

我认为问题在于您定义字符串类型的方式。请注意,在 WinRT XAML 中,它现在写为 x:String

所以这应该可行 -

<DataTemplate x:Key="GroupTemplate" x:DataType="x:String">
<TextBlock Text="{x:Bind}" />
</DataTemplate>

关于c# - 我怎么能{x :Bind} to a DataTemplate's root type in UWP?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32878726/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com