Skip to content

Commit 948b133

Browse files
chore: maximize example
1 parent 517fe86 commit 948b133

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

README.md

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,10 @@ It is also possible to configure these values through `appsettings.json` like so
103103
}
104104
}
105105
```
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.
108110
109111
## Custom Window Chrome & Draggable Regions
110112
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`:
168170
}
169171
}
170172
```
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-
174173
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.
175174

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+
176196
## Issues
177197
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

Comments
 (0)