LoadFromXaml at runtime
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"> <ContentView.Resources> <Style x:Key="Big" TargetType="Label"> <Setter Property="FontSize" Value="24" /> <Setter Property="FontAttributes" Value="Bold" /> </Style> </ContentView.Resources> <VerticalStackLayout Spacing="8"> <Label Text="Loaded at runtime" Style="{StaticResource Big}" AutomationId="rtTitle" /> <Label Text="{Binding Name, StringFormat='Hello {0}'}" AutomationId="rtBinding" /> <Entry Text="{Binding Name}" Placeholder="Edit the bound name" AutomationId="rtEntry" /> <Grid ColumnDefinitions="*,*" ColumnSpacing="8"> <BoxView Color="#FF9500" HeightRequest="30" CornerRadius="8" /> <BoxView Grid.Column="1" Color="#5856D6" HeightRequest="30" CornerRadius="8" /> </Grid> <Label Text="Trigger target" AutomationId="rtTrigger"> <Label.Triggers> <DataTrigger TargetType="Label" Binding="{Binding Name}" Value="trigger"> <Setter Property="TextColor" Value="Red" /> </DataTrigger> </Label.Triggers> </Label> </VerticalStackLayout> </ContentView>
Render XAML
Set name from code
Push XAML page
XAML error: Sequence contains no matching element