Clarify location of InitializeComponent method (#27962)

pull/27958/head
Luke Latham 2022-12-23 04:33:31 -06:00 committed by GitHub
parent cc2bbc66ec
commit ac549b36c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -221,7 +221,7 @@ using Microsoft.AspNetCore.Components.WebView.WindowsForms;
using Microsoft.Extensions.DependencyInjection;
```
Inside the `Form1` constructor, after the `InitializeComponent()` method call, add the following code:
Inside the `Form1` constructor, after the `InitializeComponent` method call, add the following code:
```csharp
var services = new ServiceCollection();
@ -231,6 +231,9 @@ blazorWebView1.Services = services.BuildServiceProvider();
blazorWebView1.RootComponents.Add<Counter>("#app");
```
> [!NOTE]
> The `InitializeComponent` method is generated by a source generator at app build time and added to the compilation object for the calling class.
The final, complete C# code of `Form1.cs`:
```csharp

View File

@ -234,7 +234,7 @@ Add the namespace <xref:Microsoft.Extensions.DependencyInjection?displayProperty
using Microsoft.Extensions.DependencyInjection;
```
Inside the `MainWindow` constructor, after the `InitializeComponent()` method call, add the following code:
Inside the `MainWindow` constructor, after the `InitializeComponent` method call, add the following code:
```csharp
var serviceCollection = new ServiceCollection();
@ -242,6 +242,9 @@ serviceCollection.AddWpfBlazorWebView();
Resources.Add("services", serviceCollection.BuildServiceProvider());
```
> [!NOTE]
> The `InitializeComponent` method is generated by a source generator at app build time and added to the compilation object for the calling class.
The final, complete C# code of `MainWindow.xaml.cs`:
```csharp