I'm trying to use an inline data source for a data grid, and obviously XAML supports array of builtin types with x:Array, but when I tried to declare a nested array, tried a few ways but none of them works.
<x:Array Type="{x:Type Array}">
<x:Array Type="{x:Type x:String}">
<x:String>aaa1</x:String>
<x:String>aaa2</x:String>
</x:Array>
<x:Array Type="{x:Type x:String}">
<x:String>aaa9</x:String>
<x:String>aaa10</x:String>
</x:Array>
</x:Array>
This wont work either:
<x:Array Type="{x:Type {x:Array Type={x:Type String}}">
Try this:
<x:Array xmlns:s="clr-namespace:System;assembly=mscorlib" x:Key="array" Type="{x:Type s:Array}">
<x:Array Type="{x:Type s:String}">
<s:String>aaa1</s:String>
<s:String>aaa2</s:String>
</x:Array>
<x:Array Type="{x:Type s:String}">
<s:String>aaa9</s:String>
<s:String>aaa10</s:String>
</x:Array>
</x:Array>
Sample usage:
<ItemsControl ItemsSource="{StaticResource array}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<ItemsControl ItemsSource="{Binding}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With