You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
2.8 KiB
55 lines
2.8 KiB
<?xml version="1.0" encoding="utf-8" ?>
|
|
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
|
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
|
|
x:Class="ex_BindingToA2dArray_v1.MainPage">
|
|
<ContentPage.Resources>
|
|
<ResourceDictionary>
|
|
<x:Double x:Key="CellWidth">100</x:Double>
|
|
<x:Double x:Key="CellHeight">100</x:Double>
|
|
<x:Double x:Key="VerticalSpacing">10</x:Double>
|
|
<x:Double x:Key="HorizontalSpacing">10</x:Double>
|
|
<toolkit:MultiMathExpressionConverter x:Key="multiMathExpressionConverter" />
|
|
</ResourceDictionary>
|
|
</ContentPage.Resources>
|
|
<CollectionView ItemsSource="{Binding Matrix.FlatMatrix2d}"
|
|
BackgroundColor="Azure"
|
|
HorizontalOptions="Center"
|
|
VerticalOptions="Center">
|
|
<CollectionView.HeightRequest>
|
|
<MultiBinding Converter="{StaticResource multiMathExpressionConverter}" ConverterParameter="x0 * x1 +(x0 - 1) * x2 ">
|
|
<Binding Path="Matrix.NbRows" />
|
|
<Binding Source="{StaticResource CellHeight}" />
|
|
<Binding Source="{StaticResource VerticalSpacing}" />
|
|
</MultiBinding>
|
|
</CollectionView.HeightRequest>
|
|
<CollectionView.WidthRequest>
|
|
<MultiBinding Converter="{StaticResource multiMathExpressionConverter}" ConverterParameter="x0 * x1 +(x0 - 1) * x2 ">
|
|
<Binding Path="Matrix.NbColumns" />
|
|
<Binding Source="{StaticResource CellWidth}" />
|
|
<Binding Source="{StaticResource HorizontalSpacing}" />
|
|
</MultiBinding>
|
|
</CollectionView.WidthRequest>
|
|
<CollectionView.ItemsLayout>
|
|
<GridItemsLayout Orientation="Vertical"
|
|
Span="{Binding Matrix.NbColumns}"
|
|
HorizontalItemSpacing="{StaticResource HorizontalSpacing}"
|
|
VerticalItemSpacing="{StaticResource VerticalSpacing}"/>
|
|
</CollectionView.ItemsLayout>
|
|
<CollectionView.ItemTemplate>
|
|
<DataTemplate>
|
|
<Border WidthRequest="{StaticResource CellWidth}"
|
|
HeightRequest="{StaticResource CellHeight}"
|
|
BackgroundColor="DarkSalmon">
|
|
<Label Text="{Binding}"
|
|
TextColor="Black"
|
|
FontSize="Medium"
|
|
HorizontalTextAlignment="Center"
|
|
VerticalTextAlignment="Center"/>
|
|
</Border>
|
|
</DataTemplate>
|
|
</CollectionView.ItemTemplate>
|
|
</CollectionView>
|
|
|
|
</ContentPage>
|