简体   繁体   English

(多)在 UWP 或 WinUI3 中将列表绑定到 TextBlock

[英](Multi)Binding a List to a TextBlock in UWP or WinUI3

This post would have been the answer but it only works in WPF. 这篇文章本来就是答案,但它只适用于 WPF。 UWP and WinUI3 don't have Multibinding. UWP 和 WinUI3 没有多重绑定。

How do you make that code in UWP/WinUI3?你如何在 UWP/WinUI3 中编写该代码?

(Multi)Binding a List to a TextBlock in UWP or WinUI3 (多)在 UWP 或 WinUI3 中将列表绑定到 TextBlock

As Johnny Westlake said you could use x:bind method to binding a list to a TextBlock .正如 Johnny Westlake 所说,您可以使用 x:bind 方法将列表绑定到TextBlock For example, Use String.Format method to format list then render in the TextBlock .例如,使用String.Format方法格式化列表,然后在TextBlock中呈现。 For more please refer this document .有关更多信息,请参阅此文档

<Page 
     xmlns:sys="using:System"
     xmlns:local="using:MyNamespace">
   <ListView ItemsSource="{x:Bind Items}">


 <ListView.ItemTemplate>
        <DataTemplate x:DataType="local:Item">
            <TextBlock Text="{x:Bind sys:String.Format(x:Null, '{0} is now available in {1}', FirstName, LastName)}"/>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

</Page>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM