Finalized Maui-series for vs development

This commit is contained in:
2025-08-21 22:08:06 +02:00
parent 543b9c2aaf
commit 8b7afd50a4
10 changed files with 95 additions and 13 deletions

View File

@ -1,8 +1,10 @@
<?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"
xmlns:vm="clr-namespace:AdventureWorks.MAUI.CommandClasses"
x:Class="AdventureWorks.MAUI.Views.ProductDetailView"
xmlns:partial="clr-namespace:AdventureWorks.MAUI.ViewsPartial"
x:DataType="vm:ProductViewModelCommands"
Title="Product Information">
<Border Style="{StaticResource Border.Page}">

View File

@ -1,9 +1,24 @@
using AdventureWorks.MAUI.CommandClasses;
namespace AdventureWorks.MAUI.Views;
[QueryProperty(nameof(ProductId), "id")]
public partial class ProductDetailView : ContentPage
{
public ProductDetailView()
{
InitializeComponent();
}
public ProductDetailView(ProductViewModelCommands viewModel)
{
InitializeComponent();
ViewModel = viewModel;
}
public ProductViewModelCommands ViewModel { get; set; }
public int ProductId { get; set; }
protected override void OnAppearing()
{
base.OnAppearing();
BindingContext = ViewModel;
//ViewModel.GetProductCategories();
//ViewModel.GetProductModels();
ViewModel.Get(ProductId);
}
}

View File

@ -6,6 +6,7 @@
xmlns:vm="clr-namespace:AdventureWorks.MAUI.CommandClasses"
xmlns:model="clr-namespace:AdventureWorks.EntityLayer;assembly=AdventureWorks.EntityLayer"
x:DataType="vm:ProductViewModelCommands"
x:Name="ProductListPage"
Title="ProductListView">
<Border Style="{StaticResource Screen.Border}">
<Grid>
@ -36,7 +37,9 @@
<Label Text="{Binding ListPrice, StringFormat='{0:C}'}" />
</HorizontalStackLayout>
<HorizontalStackLayout>
<Button Text="Edit" />
<Button Text="Edit"
CommandParameter="{Binding ProductID}"
Command="{Binding Source={x:Reference ProductListPage}, Path=BindingContext.EditCommand}"/>
<Button Text="Delete" />
</HorizontalStackLayout>
</VerticalStackLayout>

View File

@ -1,7 +1,7 @@
using AdventureWorks.MAUI.CommandClasses;
namespace AdventureWorks.MAUI.Views;
[QueryProperty(nameof(UserId), "id")]
public partial class UserDetailView : ContentPage
{
public UserDetailView(UserViewModelCommands viewModel)
@ -11,6 +11,7 @@ public partial class UserDetailView : ContentPage
}
public UserViewModelCommands ViewModel { get; set; }
public int UserId { get; set; }
protected override void OnAppearing()
{
@ -20,7 +21,7 @@ public partial class UserDetailView : ContentPage
ViewModel.GetPhoneTypes();
ViewModel.Get(1); // Assuming you want to get the user with ID 1
ViewModel.Get(UserId);
}
}

View File

@ -6,7 +6,7 @@
xmlns:model="clr-namespace:AdventureWorks.EntityLayer;assembly=AdventureWorks.EntityLayer"
x:Class="AdventureWorks.MAUI.Views.UserListView"
x:DataType="vm:UserViewModelCommands"
x:Name="UserListPage"
Title="User List">
<Border Style="{StaticResource Screen.Border}">
@ -35,7 +35,9 @@
<Label Text="{Binding Email}" />
</HorizontalStackLayout>
<HorizontalStackLayout>
<Button Text="Edit" />
<Button Text="Edit"
CommandParameter="{Binding UserId}"
Command="{Binding Source={x:Reference UserListPage}, Path=BindingContext.EditCommand}" />
<Button Text="Delete" />
</HorizontalStackLayout>
</VerticalStackLayout>