Multi-Value XAML Array

Nathan Sokalski 4,116 Reputation points

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:

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

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!

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

1 answer

Sort by: Most helpful
  1. Joe Manke 1,091 Reputation points

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