You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+25-5Lines changed: 25 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -103,8 +103,10 @@ It is also possible to configure these values through `appsettings.json` like so
103
103
}
104
104
}
105
105
```
106
-
107
-
**The `Window` object itself is also made available inside of the DI container, so you can access all properties on it by using the inject Razor keyword or requesting it through the constructor of a class added as a service.**
106
+
> [!NOTE]
107
+
> The `Window` object itself is also made available inside of the DI container by injecting `BlazorDesktopWindow`, so you can access all properties on it by using the inject Razor keyword or requesting it through the constructor of a class added as a service.
108
+
> The `BlazorDesktopWindow` inherits from the WPF `Window` class, as such you use WPF apis to manipulate it. WPF documentation for the Window class can be found [here](https://learn.microsoft.com/en-us/dotnet/api/system.windows.window?view=windowsdesktop-9.0).
109
+
> Examples of usage can be found below.
108
110
109
111
## Custom Window Chrome & Draggable Regions
110
112
It is possible to make your own window chrome for Blazor Desktop apps. As an example base setup you could do the following:
@@ -168,10 +170,28 @@ Here is an example changing `MainLayout.razor`:
168
170
}
169
171
}
170
172
```
171
-
> [!NOTE]
172
-
> The `BlazorDesktopWindow` inherits from the WPF `Window` class, as such you use WPF apis to manipulate it. WPF documentation for the Window class can be found [here](https://learn.microsoft.com/en-us/dotnet/api/system.windows.window?view=windowsdesktop-9.0).
173
-
174
173
To support fullscreen mode, you should also hide your custom window chrome when in fullscreen. You can check the current fullscreen status using the `IsFullscreen` property on the window. You can also monitor for it changing using the `OnFullscreenChanged` event.
175
174
175
+
## Changing Window Properties During Startup
176
+
It is possible to customize window startup behaviors for Blazor Desktop apps. As an example base setup you could do the following:
177
+
178
+
Using the base template, if you were to edit `MainLayout.razor` and inject the `BlazorDesktopWindow` you can have the window be maximized on launch using Blazor's `OnInitialized` lifecycle method:
179
+
```razor
180
+
@using BlazorDesktop.Wpf
181
+
@using System.Windows
182
+
@inherits LayoutComponentBase
183
+
184
+
@inject BlazorDesktopWindow window
185
+
186
+
...
187
+
188
+
@code {
189
+
protected override void OnInitialized()
190
+
{
191
+
window.WindowState = WindowState.Maximized;
192
+
}
193
+
}
194
+
```
195
+
176
196
## Issues
177
197
Under the hood, Blazor Desktop uses WebView2 which has limitations right now with composition. Due to this, if you disable the window border through the `Window.UseFrame(false)` API, the top edge of the window is unusable as a resizing zone for the window. However all the other corners and edges work.
0 commit comments