Clarify location of InitializeComponent method (#27962)
parent
cc2bbc66ec
commit
ac549b36c3
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue