Skip to content

Commit

Permalink
chore: updating sample
Browse files Browse the repository at this point in the history
  • Loading branch information
dansiegel authored and nickrandolph committed Jul 25, 2023
1 parent f13d363 commit 9afa41e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
25 changes: 25 additions & 0 deletions samples/MauiEmbedding/MauiEmbedding/Presentation/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,41 @@
mc:Ignorable="d"
xmlns:uen="using:Uno.Extensions.Navigation.UI"
xmlns:utu="using:Uno.Toolkit.UI"
xmlns:embed="using:Uno.Extensions.Maui"
xmlns:maui="using:Microsoft.Maui.Controls"
NavigationCacheMode="Required"
Background="{ThemeResource BackgroundBrush}">

<Page.Resources>
<ResourceDictionary>
<x:String x:Key="HelloWorld">Hello from WinUI Resources</x:String>
<Color x:Key="DemoColor">#169420</Color>
<local:TitleConverter x:Key="TitleConverter" />
</ResourceDictionary>
</Page.Resources>

<Grid utu:SafeArea.Insets="All">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<utu:NavigationBar Content="{Binding Title}" />

<embed:MauiContent Grid.Row="1">
<maui:ScrollView>
<maui:ScrollView.Content>
<maui:VerticalStackLayout Spacing="16">
<maui:Label Text="{embed:MauiResource Key=HelloWorld}"
TextColor="{embed:MauiResource Key=DemoColor}" />
<maui:BoxView BackgroundColor="{embed:MauiColor Value='#696969'}"
HeightRequest="3"
Margin="{embed:MauiThickness Value='10,20,30,40'}"/>
<maui:Label Text="{embed:MauiBinding Path=Title, Converter={StaticResource TitleConverter}}" />
</maui:VerticalStackLayout>
</maui:ScrollView.Content>
</maui:ScrollView>
</embed:MauiContent>

<StackPanel Grid.Row="1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Text.RegularExpressions;

namespace MauiEmbedding.Presentation;

public class TitleConverter : Microsoft.UI.Xaml.Data.IValueConverter
{
public object Convert(object? value, Type targetType, object parameter, string language) => $"Converted: {value}";
public object ConvertBack(object? value, Type targetType, object parameter, string language) => Regex.Replace(value?.ToString() ?? string.Empty, "(Converted: )", string.Empty);
}

0 comments on commit 9afa41e

Please sign in to comment.