Partial views, filling up UI

This commit is contained in:
2025-08-17 17:47:32 +02:00
parent eac181fa63
commit ba8acd09e4
6 changed files with 187 additions and 39 deletions

View File

@ -71,6 +71,9 @@
</ItemGroup>
<ItemGroup>
<MauiXaml Update="ViewsPartial\HeaderView.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\ColorListView.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>

View File

@ -1,10 +1,35 @@
<?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:partial="clr-namespace:AdventureWorks.MAUI.ViewsPartial"
x:Class="AdventureWorks.MAUI.Views.LoginView"
Title="Login">
<Label Text="Login"
FontSize="Large"
HorizontalOptions="Center"
VerticalOptions="Center" />
<Grid RowDefinitions="Auto, Auto, Auto, Auto"
ColumnDefinitions="Auto, *"
Style="{StaticResource Grid.Page}">
<partial:HeaderView Grid.Row="0"
Grid.ColumnSpan="2"
ViewTitle="Login"
ViewDescription="Please enter your credentials to login." />
<Label Grid.Row="1"
Text="Login ID" />
<Entry Grid.Row="1"
Grid.Column="1"
Placeholder="Enter your username" />
<Label Grid.Row="2"
Text="Password" />
<Entry Grid.Row="2"
Grid.Column="1"
Placeholder="Enter your password"
IsPassword="True" />
<Button Grid.Row="3"
Grid.ColumnSpan="2"
Text="Login"
HorizontalOptions="Center" />
</Grid>
</ContentPage>

View File

@ -2,9 +2,81 @@
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="AdventureWorks.MAUI.Views.ProductDetailView"
Title="Product Details">
<Label Text="Product Details"
FontSize="Large"
HorizontalOptions="Center"
VerticalOptions="Center" />
xmlns:partial="clr-namespace:AdventureWorks.MAUI.ViewsPartial"
Title="Product Information">
<Grid RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto"
ColumnDefinitions="Auto, *"
Style="{StaticResource Grid.Page}">
<partial:HeaderView Grid.Row="0"
Grid.ColumnSpan="2"
ViewTitle="Product Information"
ViewDescription="Use this Screen to Modify Product Information." />
<Label Grid.Row="1"
Text="Product Name" />
<Entry Grid.Row="1"
Grid.Column="1" />
<Label Grid.Row="2"
Text="Xxx" />
<Entry Grid.Row="2"
Grid.Column="1" />
<Label Grid.Row="3"
Text="Xxx" />
<Entry Grid.Row="3"
Grid.Column="1" />
<Label Grid.Row="4"
Text="Xxx" />
<Entry Grid.Row="4"
Grid.Column="1" />
<Label Grid.Row="5"
Text="Xxx" />
<Entry Grid.Row="5"
Grid.Column="1" />
<Label Grid.Row="6"
Text="Xxx" />
<Entry Grid.Row="6"
Grid.Column="1" />
<Label Grid.Row="7"
Text="Xxx" />
<Entry Grid.Row="7"
Grid.Column="1" />
<Label Grid.Row="8"
Text="Xxx" />
<Entry Grid.Row="8"
Grid.Column="1" />
<Label Grid.Row="9"
Text="Model" />
<Entry Grid.Row="9"
Grid.Column="1" />
<Label Grid.Row="10"
Text="Selling Start Date" />
<Entry Grid.Row="10"
Grid.Column="1" />
<Label Grid.Row="11"
Text="Selling End Date" />
<Entry Grid.Row="11"
Grid.Column="1" />
<Label Grid.Row="12"
Text="Discontinued Date" />
<Entry Grid.Row="12"
Grid.Column="1" />
<HorizontalStackLayout Grid.Row="13"
Grid.ColumnSpan="1">
<Button Text="Save" />
<Button Text="Cancel" />
</HorizontalStackLayout>
</Grid>
</ContentPage>

View File

@ -2,31 +2,22 @@
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="AdventureWorks.MAUI.Views.UserDetailView"
xmlns:partial="clr-namespace:AdventureWorks.MAUI.ViewsPartial"
Title="User Information">
<Grid RowDefinitions="Auto,Auto,Auto, Auto, Auto,Auto, Auto, Auto , Auto"
<Grid RowDefinitions="Auto, Auto, Auto,Auto, Auto, Auto , Auto"
ColumnDefinitions="Auto, *"
Style="{StaticResource Grid.Page}">
<Label Grid.Row="0"
<partial:HeaderView Grid.Row="0"
Grid.ColumnSpan="2"
Text="User Information"
FontSize="Title" />
ViewTitle="User Information"
ViewDescription="Use this Screen to Modify User Information." />
<Label Grid.Row="1"
Grid.ColumnSpan="2"
Text="Use this Screen to Modify User Information."
FontSize="Body" />
<BoxView Grid.Row="2"
Grid.ColumnSpan="2"
Margin="0,0,0,20"
HeightRequest="1"
Color="Black" />
<Label Grid.Row="3"
Text="Login ID" />
<VerticalStackLayout Grid.Row="3"
Grid.Column="1">
<Entry Text=""
@ -34,22 +25,24 @@
<Label FontSize="Micro"
Text="Please use a combination of letters and numbers." />
</VerticalStackLayout>
<Label Grid.Row="4"
<Label Grid.Row="2"
Text="First Name" />
<Entry Grid.Row="2"
Grid.Column="1"
Text=""/>
<Label Grid.Row="3"
Text="Last Name" />
<Entry Grid.Row="3"
Grid.Column="1"
Text=""/>
<Label Grid.Row="4"
Text="Email Address" />
<Entry Grid.Row="4"
Grid.Column="1"
Text=""/>
<Label Grid.Row="5"
Text="Last Name" />
<Entry Grid.Row="5"
Grid.Column="1"
Text=""/>
<Label Grid.Row="6"
Text="Email Address" />
<Entry Grid.Row="6"
Grid.Column="1"
Text=""/>
<FlexLayout Grid.Row="7"
<Label Grid.Row="5" Text="Is Enrolled ?"/>
<FlexLayout Grid.Row="5"
Grid.Column="1"
Wrap="Wrap"
Direction="Row">
@ -70,7 +63,7 @@
<CheckBox IsChecked="True"/>
</HorizontalStackLayout>
</FlexLayout>
<HorizontalStackLayout Grid.Row="8"
<HorizontalStackLayout Grid.Row="6"
Grid.Column="1"
Spacing="5">
<Button Text="Save" />

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="AdventureWorks.MAUI.ViewsPartial.HeaderView">
<Grid RowDefinitions="Auto,Auto,Auto">
<Label Grid.Row="0"
Text="{Binding ViewTitle}"
HorizontalOptions="Center"
FontSize="Title" />
<Label Grid.Row="1"
Grid.ColumnSpan="2"
Text="{Binding ViewDescription}"
HorizontalOptions="Center"
FontSize="Body" />
<BoxView Grid.Row="2"
Grid.ColumnSpan="2"
Margin="0,0,0,20"
HeightRequest="1"
Color="Black" />
</Grid>
</ContentView>

View File

@ -0,0 +1,30 @@
namespace AdventureWorks.MAUI.ViewsPartial;
public partial class HeaderView : ContentView
{
public HeaderView()
{
InitializeComponent();
ViewTitle = "View Title";
ViewDescription = "View Description";
this.BindingContext = this;
}
public string ViewTitle
{
get { return (string)GetValue(ViewTitleProperty); }
set { SetValue(ViewTitleProperty, value); }
}
public string ViewDescription
{
get { return (string)GetValue(ViewDescriptionProperty); }
set { SetValue(ViewDescriptionProperty, value); }
}
public static readonly BindableProperty ViewTitleProperty =
BindableProperty.Create(nameof(ViewTitle), typeof(string), typeof(HeaderView), string.Empty);
public static readonly BindableProperty ViewDescriptionProperty =
BindableProperty.Create(nameof(ViewDescription), typeof(string), typeof(HeaderView), default(string));
}