0

This post would have been the answer but it only works in WPF. UWP and WinUI3 don't have Multibinding.

How do you make that code in UWP/WinUI3?

On The Net Again
  • 265
  • 4
  • 16
  • 1
    Can you give a scenario? x:Bind methods can take multiple parameters so could be used depending on what exactly you want. – Johnny Westlake Mar 08 '21 at 17:17
  • https://stackoverflow.com/a/8847910/6067603 The code in this post is exactly what I want to do. But I have no idea how to do that in UWP/WinUI3. – On The Net Again Mar 08 '21 at 17:52

2 Answers2

1

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

As Johnny Westlake said you could use x:bind method to binding a list to a TextBlock. For example, Use String.Format method to format list then render in the 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>
Nico Zhu
  • 32,367
  • 2
  • 15
  • 36
0

I believe that sys:String.Format is winui3 with the UWP interface, but if you are using the newer winui3 "Microsoft:" (rather than "Windows:") Win App SDK interface, it is not supported. What is the best way to achieve equivalent under the newest interface, not the UWP interface?

Mart
  • 31
  • 2