Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public static MauiApp CreateMauiApp()

builder.Services.AddSingleton<MonkeyService>();
builder.Services.AddSingleton<MonkeysViewModel>();
builder.Services.AddSingleton<MainPage>();


builder.Services.AddTransient<MonkeyDetailsViewModel>();
builder.Services.AddTransient<DetailsPage>();


return builder.Build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public static MauiApp CreateMauiApp()

builder.Services.AddSingleton<MonkeyService>();
builder.Services.AddSingleton<MonkeysViewModel>();
builder.Services.AddSingleton<MainPage>();


builder.Services.AddTransient<MonkeyDetailsViewModel>();
builder.Services.AddTransient<DetailsPage>();


return builder.Build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public static MauiApp CreateMauiApp()

builder.Services.AddSingleton<MonkeyService>();
builder.Services.AddSingleton<MonkeysViewModel>();
builder.Services.AddSingleton<MainPage>();


builder.Services.AddTransient<MonkeyDetailsViewModel>();
builder.Services.AddTransient<DetailsPage>();


return builder.Build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public static MauiApp CreateMauiApp()

builder.Services.AddSingleton<MonkeyService>();
builder.Services.AddSingleton<MonkeysViewModel>();
builder.Services.AddSingleton<MainPage>();


builder.Services.AddTransient<MonkeyDetailsViewModel>();
builder.Services.AddTransient<DetailsPage>();


return builder.Build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public static MauiApp CreateMauiApp()

builder.Services.AddSingleton<MonkeyService>();
builder.Services.AddSingleton<MonkeysViewModel>();
builder.Services.AddSingleton<MainPage>();


builder.Services.AddTransient<MonkeyDetailsViewModel>();
builder.Services.AddTransient<DetailsPage>();


return builder.Build();
}
Expand Down
4 changes: 1 addition & 3 deletions Finish/MonkeyFinder/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ public static MauiApp CreateMauiApp()

builder.Services.AddSingleton<MonkeyService>();
builder.Services.AddSingleton<MonkeysViewModel>();
builder.Services.AddSingleton<MainPage>();

builder.Services.AddTransient<MonkeyDetailsViewModel>();
builder.Services.AddTransient<DetailsPage>();

builder.Services.AddSingleton<DetailsPage>();
return builder.Build();
}
}
2 changes: 1 addition & 1 deletion Part 1 - Displaying Data/MonkeyFinder/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static MauiApp CreateMauiApp()
builder.Logging.AddDebug();
#endif

builder.Services.AddSingleton<MainPage>();


return builder.Build();
}
Expand Down
2 changes: 1 addition & 1 deletion Part 2 - MVVM/MonkeyFinder/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static MauiApp CreateMauiApp()
builder.Logging.AddDebug();
#endif

builder.Services.AddSingleton<MainPage>();


return builder.Build();
}
Expand Down
2 changes: 1 addition & 1 deletion Part 3 - Navigation/MonkeyFinder/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static MauiApp CreateMauiApp()

builder.Services.AddSingleton<MonkeyService>();
builder.Services.AddSingleton<MonkeysViewModel>();
builder.Services.AddSingleton<MainPage>();


return builder.Build();
}
Expand Down
4 changes: 3 additions & 1 deletion Part 3 - Navigation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,11 @@ Now that we have our details page in place, we need to register it for routing.

```csharp
builder.Services.AddTransient<MonkeyDetailsViewModel>();
builder.Services.AddTransient<DetailsPage>();

```

> Starting in .NET 9 you no longer need to register Pages with the dependency service for constructor injection to work. By default when we navigate to a new page it will be created an the `MonkeyDetailsViewModel` will be injected as well.

1. Finally, we must inject the view model into our `DetailsPage`. Open the code behind for the page in `DetailsPage.xaml.cs` and change the constructor to the following:

```csharp
Expand Down
4 changes: 3 additions & 1 deletion Part 3 - Navigation/README.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,11 @@ public partial class DetailsPage : ContentPage

```csharp
builder.Services.AddTransient<MonkeyDetailsViewModel>();
builder.Services.AddTransient<DetailsPage>();

```

> Starting in .NET 9 you no longer need to register Pages with the dependency service for constructor injection to work. By default when we navigate to a new page it will be created an the `MonkeyDetailsViewModel` will be injected as well.

3. 最后,我们必须将视图模型注入到我们的 `DetailsPage` 中。 在 `DetailsPage.xaml.cs` 中打开页面背后的代码,并将构造函数更改为以下内容:

```csharp
Expand Down
3 changes: 2 additions & 1 deletion Part 3 - Navigation/README.zh-tw.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,9 @@ public partial class DetailsPage : ContentPage

```csharp
builder.Services.AddTransient<MonkeyDetailsViewModel>();
builder.Services.AddTransient<DetailsPage>();

```
> Starting in .NET 9 you no longer need to register Pages with the dependency service for constructor injection to work. By default when we navigate to a new page it will be created an the `MonkeyDetailsViewModel` will be injected as well.

3. 最後,開啟 `DetailsPage.xaml.cs` 這個 DetailPage.xaml 所對應的後置程式碼檔案,並將 DetailPage 的建構方法改為如下內容:

Expand Down
4 changes: 2 additions & 2 deletions Part 4 - Platform Features/MonkeyFinder/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ public static MauiApp CreateMauiApp()

builder.Services.AddSingleton<MonkeyService>();
builder.Services.AddSingleton<MonkeysViewModel>();
builder.Services.AddSingleton<MainPage>();


builder.Services.AddTransient<MonkeyDetailsViewModel>();
builder.Services.AddTransient<DetailsPage>();


return builder.Build();
}
Expand Down
4 changes: 2 additions & 2 deletions Part 5 - CollectionView/MonkeyFinder/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public static MauiApp CreateMauiApp()

builder.Services.AddSingleton<MonkeyService>();
builder.Services.AddSingleton<MonkeysViewModel>();
builder.Services.AddSingleton<MainPage>();


builder.Services.AddTransient<MonkeyDetailsViewModel>();
builder.Services.AddTransient<DetailsPage>();


return builder.Build();
}
Expand Down
4 changes: 2 additions & 2 deletions Part 6 - AppThemes/MonkeyFinder/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public static MauiApp CreateMauiApp()

builder.Services.AddSingleton<MonkeyService>();
builder.Services.AddSingleton<MonkeysViewModel>();
builder.Services.AddSingleton<MainPage>();


builder.Services.AddTransient<MonkeyDetailsViewModel>();
builder.Services.AddTransient<DetailsPage>();


return builder.Build();
}
Expand Down