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.
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 @@ -120,6 +120,7 @@ public override string ToString()
new GalleryPageFactory(() => new GridControlPage(), "Grid Feature Matrix"),
new GalleryPageFactory(() => new LayoutFeaturePage(), "ScrollView With LayoutOptions Feature Matrix"),
new GalleryPageFactory(() => new ShellFeaturePage(), "Shell Feature Matrix"),
new GalleryPageFactory(() => new BrushesControlPage(), "Brushes Feature Matrix")
};


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?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.BrushesControlMainPage"
x:DataType="local:BrushesViewModel"
Title="BrushesControlPage">
<ContentPage.ToolbarItems>
<ToolbarItem Text="Options"
Clicked="OnOptionsClicked"/>
</ContentPage.ToolbarItems>
<VerticalStackLayout Padding="15"
Spacing="10">
<StackLayout>
<Label Text="Brushes Feature Matrix"
FontSize="20"
HorizontalOptions="Center"
AutomationId="BrushesLabel"/>
<BoxView HeightRequest="25"/>
<Border
WidthRequest="300"
HeightRequest="300"
StrokeThickness="30"
Stroke="{Binding StrokeBrush}"
Background="{Binding BrushTarget}"
Opacity="{Binding BrushOpacity}"
StrokeShape="RoundRectangle 30"
Shadow="{Binding ShadowBrush}">
<Label Text="Test Brushes"
HorizontalOptions="Center"
VerticalOptions="Center"/>
</Border>
</StackLayout>
<BoxView HeightRequest="30"/>
<VerticalStackLayout Spacing="5">
<HorizontalStackLayout Spacing="10"
VerticalOptions="Center"
HorizontalOptions="Center">
<Label Text="Selected Color 1:"
VerticalOptions="Center"/>
<Label Text="{Binding SelectedColorName1}"
VerticalOptions="Center"
AutomationId="Color1"/>
</HorizontalStackLayout>
<HorizontalStackLayout Spacing="10"
VerticalOptions="Center"
HorizontalOptions="Center">
<Label Text="Selected Color 2:"
VerticalOptions="Center"/>
<Label Text="{Binding SelectedColorName2}"
VerticalOptions="Center"
AutomationId="Color2"/>
</HorizontalStackLayout>
<HorizontalStackLayout Spacing="10"
VerticalOptions="Center"
HorizontalOptions="Center">
<Label Text="Compare Result:"
VerticalOptions="Center"/>
<Label Text="{Binding CompareResult}"
VerticalOptions="Center"
AutomationId="CompareResultLabel"/>
</HorizontalStackLayout>
<Button Text="Compare Selected Brushes"
Clicked="OnCompareClicked"
BackgroundColor="DarkBlue"
TextColor="White"
AutomationId="CompareButton"/>
<HorizontalStackLayout Spacing="10"
HorizontalOptions="Center">
<Button Text="Add Linear Stop"
Clicked="OnAddLinearStopClicked"
AutomationId="AddLinearStopButton"/>
<Button Text="Remove Linear Stop"
Clicked="OnRemoveLinearStopClicked"
AutomationId="RemoveLinearStopButton"/>
</HorizontalStackLayout>
<HorizontalStackLayout Spacing="10"
HorizontalOptions="Center">
<Button Text="Add Radial Stop"
Clicked="OnAddRadialStopClicked"
AutomationId="AddRadialStopButton"/>
<Button Text="Remove Radial Stop"
Clicked="OnRemoveRadialStopClicked"
AutomationId="RemoveRadialStopButton"/>
</HorizontalStackLayout>
</VerticalStackLayout>
</VerticalStackLayout>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using Microsoft.Maui.Controls;

namespace Maui.Controls.Sample;

public class BrushesControlPage : NavigationPage
{
private BrushesViewModel _viewModel;
public BrushesControlPage()
{
_viewModel = new BrushesViewModel();
PushAsync(new BrushesControlMainPage(_viewModel));
}
}

public partial class BrushesControlMainPage : ContentPage
{
private BrushesViewModel _viewModel;

public BrushesControlMainPage(BrushesViewModel viewModel)
{
InitializeComponent();
BindingContext = _viewModel = viewModel;
}

private void OnAddLinearStopClicked(object sender, EventArgs e)
{
_viewModel?.AddLinearGradientStopCommand?.Execute(null);
}

private void OnRemoveLinearStopClicked(object sender, EventArgs e)
{
_viewModel?.RemoveLinearGradientStopCommand?.Execute(null);
}

private void OnAddRadialStopClicked(object sender, EventArgs e)
{
_viewModel?.AddRadialGradientStopCommand?.Execute(null);
}

private void OnRemoveRadialStopClicked(object sender, EventArgs e)
{
_viewModel?.RemoveRadialGradientStopCommand?.Execute(null);
}

private void OnApplyLinearClicked(object sender, EventArgs e)
{
_viewModel?.ApplyLinearGradientCommand?.Execute(null);
}

private void OnApplyRadialClicked(object sender, EventArgs e)
{
_viewModel?.ApplyRadialGradientCommand?.Execute(null);
}

private void OnCompareClicked(object sender, EventArgs e)
{
if (BindingContext is BrushesViewModel vm)
{
vm.CompareBrushesCommand?.Execute(null);
}
}

private async void OnOptionsClicked(object sender, EventArgs e)
{
BindingContext = _viewModel = new BrushesViewModel();
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating a new BrushesViewModel instance overwrites the existing state when navigating to options. This will lose any previously configured brush settings. The existing _viewModel should be reused instead of creating a new instance.

Suggested change
BindingContext = _viewModel = new BrushesViewModel();

Copilot uses AI. Check for mistakes.
await Navigation.PushAsync(new BrushesOptionsPage(_viewModel));
}
}
Loading
Loading