Multi-Value XAML Array

Nathan Sokalski 4,126 Reputation points
2020-12-02T20:00:27.207+00:00

In the ItemsSource property of a CollectionView I want to place an array of an anonymous type or Tuple. Visual Studio 2019 Intellisense lets me do the following:

<CollectionView.ItemsSource>
<x:Array Type="{x:Type system:(T1, T2)`2}">
</x:Array>
</CollectionView.ItemsSource>

However, I am not sure what to do next. How do I put the data in the array, and how do I specify names (or if it is a Tuple, do I just use the default names of Item1, Item2, etc.)? I know that I could create a temporary class instead, but because this is for design time / testing only I would prefer not to do that. What should I do next, or where can I find more about Type="{x:Type system:(T1, T2)`2}"? Thanks!

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,326 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Joe Manke 1,091 Reputation points
    2020-12-02T23:19:15.193+00:00

    Any ItemsSource more complicated than int[] is very difficult to define in XAML. I would just do it in the code-behind.