Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public override string ToString()
new GalleryPageFactory(() => new ScrollViewControlPage(), "ScrollView Feature Matrix"),
new GalleryPageFactory(() => new GraphicsViewControlPage(), "GraphicsView Feature Matrix"),
new GalleryPageFactory(() => new EditorControlPage(), "Editor Feature Matrix"),
new GalleryPageFactory(() => new AbsoluteLayoutControlPage(), "AbsoluteLayout Feature Matrix"),
new GalleryPageFactory(() => new ContentViewControlPage(), "ContentView Feature Matrix")
new GalleryPageFactory(() => new ShapesControlPage(), "Shapes Feature Matrix"),
new GalleryPageFactory(() => new ContentPageControlPage(), "ContentPage Feature Matrix"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?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:local="clr-namespace:Maui.Controls.Sample"
x:Class="Maui.Controls.Sample.AbsoluteLayoutControlMainPage"
x:DataType="local:AbsoluteLayoutViewModel">
<ContentPage.ToolbarItems>
<ToolbarItem Text="Options"
Clicked="NavigateToOptionsPage_Clicked"
AutomationId="Options"/>
</ContentPage.ToolbarItems>
<AbsoluteLayout AutomationId="MainLayout"
FlowDirection="{Binding FlowDirection}"
BackgroundColor="{Binding BackgroundColor}"
IsVisible="{Binding IsVisible}">
<BoxView Color="Blue"
x:Name="AbsoluteLayoutBoxView"
AutomationId="BlueBox"
AbsoluteLayout.LayoutBounds="{Binding Bounds}"
AbsoluteLayout.LayoutFlags="{Binding LayoutFlags}"/>
<Label Text="Fixed Label"
AutomationId="FixedLabel"
TextColor="Red"
FontSize="18"
AbsoluteLayout.LayoutBounds="0.5,0,AutoSize,AutoSize"
AbsoluteLayout.LayoutFlags="PositionProportional"/>
<Button Text="Click Me"
AutomationId="ClickMeButton"
AbsoluteLayout.LayoutBounds="0.5,0.99,AutoSize,AutoSize"
AbsoluteLayout.LayoutFlags="PositionProportional"/>
</AbsoluteLayout>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Layouts;

namespace Maui.Controls.Sample;

public class AbsoluteLayoutControlPage : NavigationPage
{
private AbsoluteLayoutViewModel _viewModel;
public AbsoluteLayoutControlPage()
{
_viewModel = new AbsoluteLayoutViewModel();
PushAsync(new AbsoluteLayoutControlMainPage(_viewModel));
}
}

public partial class AbsoluteLayoutControlMainPage : ContentPage
{
private AbsoluteLayoutViewModel _viewModel;

public AbsoluteLayoutControlMainPage(AbsoluteLayoutViewModel viewModel)
{
InitializeComponent();
_viewModel = viewModel;
BindingContext = _viewModel;
}

private async void NavigateToOptionsPage_Clicked(object sender, EventArgs e)
{
BindingContext = _viewModel = new AbsoluteLayoutViewModel();
await Navigation.PushAsync(new AbsoluteLayoutOptionsPage(_viewModel));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
<?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:local="clr-namespace:Maui.Controls.Sample"
x:Class="Maui.Controls.Sample.AbsoluteLayoutOptionsPage"
Title="AbsoluteLayoutFeature">
<ContentPage.ToolbarItems>
<ToolbarItem Text="Apply"
Clicked="ApplyButton_Clicked"
AutomationId="Apply"/>
</ContentPage.ToolbarItems>
<VerticalStackLayout Padding="20"
Spacing="24">
<!-- Section: Position and Size -->
<Label Text="LayoutBounds"
FontAttributes="Bold"/>
<Grid ColumnDefinitions="Auto,*,Auto,*"
RowDefinitions="Auto,Auto"
ColumnSpacing="10">
<Label Text="X:"
Grid.Row="0"
Grid.Column="0"
VerticalOptions="Center"/>
<Entry Text="{Binding X}"
Grid.Row="0"
Grid.Column="1"
AutomationId="XEntry"/>
<Label Text="Y:"
Grid.Row="0"
Grid.Column="2"
VerticalOptions="Center"/>
<Entry Text="{Binding Y}"
Grid.Row="0"
Grid.Column="3"
AutomationId="YEntry"/>
<Label Text="Width:"
Grid.Row="1"
Grid.Column="0"
VerticalOptions="Center"/>
<Entry Text="{Binding Width}"
Grid.Row="1"
Grid.Column="1"
AutomationId="WidthEntry"/>
<Label Text="Height:"
Grid.Row="1"
Grid.Column="2"
VerticalOptions="Center"/>
<Entry Text="{Binding Height}"
Grid.Row="1"
Grid.Column="3"
AutomationId="HeightEntry"/>
</Grid>

<!-- Section: Layout Flags -->
<Label Text="LayoutFlags"
FontAttributes="Bold"/>
<Grid RowSpacing="10"
ColumnSpacing="10"
ColumnDefinitions="*,*"
RowDefinitions="Auto,Auto,Auto,Auto">
<HorizontalStackLayout Grid.Row="0"
Grid.Column="0"
Spacing="5">
<CheckBox x:Name="chkNone"
CheckedChanged="OnLayoutFlagCheckedChanged"
AutomationId="LayoutFlagNoneCheckBox"/>
<Label Text="None"
VerticalOptions="Center"/>
</HorizontalStackLayout>
<HorizontalStackLayout Grid.Row="0"
Grid.Column="1"
Spacing="5">
<CheckBox x:Name="chkX"
CheckedChanged="OnLayoutFlagCheckedChanged"
AutomationId="LayoutFlagXProportionalCheckBox"/>
<Label Text="XProportional"
VerticalOptions="Center"/>
</HorizontalStackLayout>
<HorizontalStackLayout Grid.Row="1"
Grid.Column="0"
Spacing="5">
<CheckBox x:Name="chkY"
CheckedChanged="OnLayoutFlagCheckedChanged"
AutomationId="LayoutFlagYProportionalCheckBox"/>
<Label Text="YProportional"
VerticalOptions="Center"/>
</HorizontalStackLayout>
<HorizontalStackLayout Grid.Row="1"
Grid.Column="1"
Spacing="5">
<CheckBox x:Name="chkWidth"
CheckedChanged="OnLayoutFlagCheckedChanged"
AutomationId="LayoutFlagWidthProportionalCheckBox"/>
<Label Text="WidthProportional"
VerticalOptions="Center"/>
</HorizontalStackLayout>
<HorizontalStackLayout Grid.Row="2"
Grid.Column="0"
Spacing="5">
<CheckBox x:Name="chkHeight"
CheckedChanged="OnLayoutFlagCheckedChanged"
AutomationId="LayoutFlagHeightProportionalCheckBox"/>
<Label Text="HeightProportional"
VerticalOptions="Center"/>
</HorizontalStackLayout>
<HorizontalStackLayout Grid.Row="2"
Grid.Column="1"
Spacing="5">
<CheckBox x:Name="chkPosition"
CheckedChanged="OnLayoutFlagCheckedChanged"
AutomationId="LayoutFlagPositionProportionalCheckBox"/>
<Label Text="PositionProportional"
VerticalOptions="Center"/>
</HorizontalStackLayout>
<HorizontalStackLayout Grid.Row="3"
Grid.Column="0"
Spacing="5">
<CheckBox x:Name="chkSize"
CheckedChanged="OnLayoutFlagCheckedChanged"
AutomationId="LayoutFlagSizeProportionalCheckBox"/>
<Label Text="SizeProportional"
VerticalOptions="Center"/>
</HorizontalStackLayout>
<HorizontalStackLayout Grid.Row="3"
Grid.Column="1"
Spacing="5">
<CheckBox x:Name="chkAll"
CheckedChanged="OnLayoutFlagCheckedChanged"
AutomationId="LayoutFlagAllCheckBox"/>
<Label Text="All"
VerticalOptions="Center"/>
</HorizontalStackLayout>
</Grid>

<!-- Section: Flow Direction and Visibility -->
<Grid ColumnDefinitions="Auto,Auto,Auto,Auto"
RowDefinitions="Auto,Auto"
RowSpacing="10"
ColumnSpacing="15">
<Label Text="Flow Direction"
Grid.Row="0"
Grid.Column="0"
FontAttributes="Bold"/>
<Label Text="IsVisible"
Grid.Row="0"
Grid.Column="2"
FontAttributes="Bold"/>
<RadioButton x:Name="FlowDirectionLTR"
Grid.Row="1"
Grid.Column="0"
AutomationId="FlowDirectionLTR"
GroupName="FlowDirection"
Content="LTR"
IsChecked="True"
FontSize="14"
CheckedChanged="OnFlowDirectionChanged"/>
<RadioButton x:Name="FlowDirectionRTL"
Grid.Row="1"
Grid.Column="1"
AutomationId="FlowDirectionRTL"
GroupName="FlowDirection"
Content="RTL"
FontSize="14"
CheckedChanged="OnFlowDirectionChanged"/>
<RadioButton Content="True"
Grid.Row="1"
Grid.Column="2"
IsChecked="True"
GroupName="IsVisibleGroup"
CheckedChanged="IsVisibleRadio_CheckedChanged"
AutomationId="IsVisibleTrue"/>
<RadioButton Content="False"
Grid.Row="1"
Grid.Column="3"
GroupName="IsVisibleGroup"
CheckedChanged="IsVisibleRadio_CheckedChanged"
AutomationId="IsVisibleFalse"/>
</Grid>

<!-- Section: Background Color -->
<Label Text="BackgroundColor"
FontAttributes="Bold"/>
<Grid ColumnDefinitions="Auto,Auto,Auto"
ColumnSpacing="10">
<Button Text="Red"
Clicked="OnBackgroundColorChanged"
AutomationId="BackgroundColorRedButton"/>
<Button Text="Gray"
Grid.Column="1"
Clicked="OnBackgroundColorChanged"
AutomationId="BackgroundColorGrayButton"/>
<Button Text="LightYellow"
Grid.Column="2"
Clicked="OnBackgroundColorChanged"
AutomationId="BackgroundColorLightYellowButton"/>
</Grid>
</VerticalStackLayout>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Maui.Layouts;

namespace Maui.Controls.Sample;

public partial class AbsoluteLayoutOptionsPage : ContentPage
{
private AbsoluteLayoutViewModel _viewModel;
public AbsoluteLayoutOptionsPage(AbsoluteLayoutViewModel viewModel)
{
InitializeComponent();
_viewModel = viewModel;
BindingContext = _viewModel;
}

private void ApplyButton_Clicked(object sender, EventArgs e)
{
Navigation.PopAsync();
}

private void OnLayoutFlagCheckedChanged(object sender, CheckedChangedEventArgs e)
{
AbsoluteLayoutFlags flags = AbsoluteLayoutFlags.None;

if (chkX.IsChecked)
flags |= AbsoluteLayoutFlags.XProportional;
if (chkY.IsChecked)
flags |= AbsoluteLayoutFlags.YProportional;
if (chkWidth.IsChecked)
flags |= AbsoluteLayoutFlags.WidthProportional;
if (chkHeight.IsChecked)
flags |= AbsoluteLayoutFlags.HeightProportional;
if (chkPosition.IsChecked)
flags |= AbsoluteLayoutFlags.PositionProportional;
if (chkSize.IsChecked)
flags |= AbsoluteLayoutFlags.SizeProportional;
if (chkAll.IsChecked)
flags |= AbsoluteLayoutFlags.All;

if (chkNone.IsChecked)
flags = AbsoluteLayoutFlags.None;

_viewModel.LayoutFlags = flags;
}

private void IsVisibleRadio_CheckedChanged(object sender, CheckedChangedEventArgs e)
{
if (!(sender is RadioButton rb) || !rb.IsChecked)
return;
_viewModel.IsVisible = rb.Content?.ToString() == "True";
}

private void OnFlowDirectionChanged(object sender, EventArgs e)
{
_viewModel.FlowDirection = FlowDirectionLTR.IsChecked ? FlowDirection.LeftToRight : FlowDirection.RightToLeft;
}

private void OnBackgroundColorChanged(object sender, EventArgs e)
{
if (BindingContext is AbsoluteLayoutViewModel vm && sender is Button button && button.Text is string color)
{
switch (color)
{
case "Red":
vm.BackgroundColor = Colors.Red;
break;
case "Gray":
vm.BackgroundColor = Colors.Gray;
break;
case "LightYellow":
vm.BackgroundColor = Colors.LightYellow;
break;
default:
vm.BackgroundColor = Colors.White;
break;
}
}
}
}
Loading