Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1134 Update samples #1219

Merged
merged 9 commits into from
Jun 13, 2023
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
xmlns:pages="clr-namespace:CommunityToolkit.Maui.Sample.Pages"
xmlns:mct="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
xmlns:vm="clr-namespace:CommunityToolkit.Maui.Sample.ViewModels.Behaviors"
xmlns:system="clr-namespace:System;assembly=mscorlib"
x:Class="CommunityToolkit.Maui.Sample.Pages.Behaviors.EventToCommandBehaviorPage"
x:TypeArguments="vm:EventToCommandBehaviorViewModel"
x:DataType="vm:EventToCommandBehaviorViewModel">
Expand All @@ -16,7 +17,7 @@

<Label Text="{Binding ClickCount, StringFormat='{0} clicks'}" />

<Button Text="Click Me"
<Button Text="Increment (No Args)"
TextColor="White"
BackgroundColor="{StaticResource NormalButtonBackgroundColor}">
<Button.Behaviors>
Expand All @@ -25,5 +26,17 @@
Command="{Binding IncrementCommand}" />
</Button.Behaviors>
</Button>


<Button Text="Click Me (Pass event args)"
TextColor="White"
BackgroundColor="{StaticResource NormalButtonBackgroundColor}">
<Button.Behaviors>
<mct:EventToCommandBehavior
x:TypeArguments="system:EventArgs"
EventName="Clicked"
Command="{Binding IncrementCommand2}" />
</Button.Behaviors>
</Button>
</VerticalStackLayout>
</pages:BasePage>
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ public ExpanderPageCS()
{
Title = "Expander Page, C# UI";

var button = new Button()
.Text("Learn more");
button.Clicked += (s,e) => Launcher.OpenAsync("https://dot.net/maui");
VladislavAntonyuk marked this conversation as resolved.
Show resolved Hide resolved
Content = new VerticalStackLayout()
{
Spacing = 12,
Expand Down Expand Up @@ -40,7 +43,9 @@ public ExpanderPageCS()

new Label()
.Text(".NET Multi-platform App UI (.NET MAUI) is a cross-platform framework for creating mobile and desktop apps with C# and XAML. Using .NET MAUI, you can develop apps that can run on Android, iOS, iPadOS, macOS, and Windows from a single shared codebase.")
.Font(italic: true)
.Font(italic: true),

button
VladislavAntonyuk marked this conversation as resolved.
Show resolved Hide resolved

}.Padding(10)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ public partial class EventToCommandBehaviorViewModel : BaseViewModel
public EventToCommandBehaviorViewModel()
{
IncrementCommand = new Command(() => ClickCount++);
IncrementCommand2 = new Command<EventArgs>((args) => ClickCount++);
}

public ICommand IncrementCommand { get; }
public ICommand IncrementCommand2 { get; }
}