【发布时间】:2018-08-07 15:34:30
【问题描述】:
假设我有一个用于 ListView 的简单 ItemTemplate
<ListView ItemsSource="{x:Bind ListItems}">
<ListView.ItemTemplate>
<DataTemplate x:DataType="local:TextItem">
<TextBlock Text="{x:Bind Item}"/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
MainPage.xaml
当我运行该应用程序时,我得到一个填充有 TextBlocks 的 ListView - ListItems 中的每个项目都有一个(这是一个后面定义的变量)。但是,在 XAML 设计器中,我什么也看不到。
那么,有没有办法在 XAML 设计器中预览 ItemTemplate/DataTemplate,用一组占位符文本块替换 Text="{x:Bind Item}"?还是只预览一个 TextBlock?
这不是重复
Design View of a DataTemplate in a ResourceDictionary in Visual Studio - 因为我不能使用 Blend。我查到的所有关于以某种方式使用 Blend 的信息都只是告诉我“此功能不适用于针对“Windows 10 Fall Creators Update (10.0; Build 16299)”的项目”
Can I preview my DataTemplate(s) in my collection-based controls in the designer? - 好吧,也许是这样,但我不明白接受的答案,现在已经有几年了。包含针对我的问题量身定制的示例的答案将非常有帮助。
【问题讨论】:
-
如果需要的话,我一会儿可以加后面的代码
-
您似乎正在为 UWP 中的设计时数据寻找解决方案...... MSDN 上应该有几个可用的链接,也许检查一下?像 docs.microsoft.com/en-us/windows/uwp/data-binding/… 但 FCU developercommunity.visualstudio.com/content/problem/172286/… 似乎确实存在问题@
-
@Depechie 我已阅读该文档页面,但它说“如果您使用的是
{x:Bind},那么您的绑定至少会在设计表面上显示占位符值”。也许这与阻止使用 Blend 的明显错误有关?如果是这样,我只能等他们修补它 -
可以使用 Blend 吗?它可以看到它。
-
@lindexi 不,我不能使用 Blend,因为使用它的所有说明都会导致我看到消息“此功能不适用于针对“Windows 10 Fall Creators Update (10.0; Build 16299) 的项目)"',这可能是因为一个错误,正如 Depechie 所建议的那样
标签: visual-studio uwp visual-studio-2017 uwp-xaml