Skip to content

Commit

Permalink
Update template sample
Browse files Browse the repository at this point in the history
  • Loading branch information
rachelkang committed Jun 25, 2024
1 parent 8008fe8 commit edf0b31
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
12 changes: 5 additions & 7 deletions newBinding/sample/MauiSample/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,14 @@
SemanticProperties.HeadingLevel="Level1" />

<Label
Text="Welcome to &#10;.NET Multi-platform App UI"
Text="Create new bindings using Native Library Interop"
Style="{StaticResource SubHeadline}"
SemanticProperties.HeadingLevel="Level2"
SemanticProperties.Description="Welcome to dot net Multi platform App U I" />
SemanticProperties.HeadingLevel="Level2" />

<Button
x:Name="CounterBtn"
Text="Click me"
SemanticProperties.Hint="Counts the number of times you click"
Clicked="OnCounterClicked"
Text="Get Started"
SemanticProperties.Hint="Navigates to getting started documentation"
Clicked="OnDocsButtonClicked"
HorizontalOptions="Fill" />
</VerticalStackLayout>
</ScrollView>
Expand Down
27 changes: 15 additions & 12 deletions newBinding/sample/MauiSample/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,29 @@ public MainPage()
{
InitializeComponent();

string myName = "Community Toolkit";

#if IOS || MACCATALYST
string labelText = NewBinding.DotnetNewBinding.GetStringWithMyString(new Foundation.NSString("Rachel"));
string labelText = NewBinding.DotnetNewBinding.GetStringWithMyString(new Foundation.NSString(myName));
#elif ANDROID
var dotnetNewBinding = new NewBinding.DotnetNewBinding();
string labelText = dotnetNewBinding.GetString("Rachel") ?? string.Empty;
string labelText = dotnetNewBinding.GetString(myName) ?? string.Empty;
#endif

newBindingSampleLabel.Text = "Hello, " + labelText;
newBindingSampleLabel.Text = "Hello, " + labelText + "!";
}

private void OnCounterClicked(object sender, EventArgs e)
private async void OnDocsButtonClicked(object sender, EventArgs e)
{
count++;

if (count == 1)
CounterBtn.Text = $"Clicked {count} time";
else
CounterBtn.Text = $"Clicked {count} times";

SemanticScreenReader.Announce(CounterBtn.Text);
try
{
Uri uri = new Uri("https://learn.microsoft.com/dotnet/communitytoolkit/maui/native-library-interop/get-started");
await Browser.Default.OpenAsync(uri, BrowserLaunchMode.SystemPreferred);
}
catch (Exception ex)
{
throw new Exception("Browser failed to launch", ex);
}
}
}

0 comments on commit edf0b31

Please sign in to comment.