# \[Code template\] WPF window registration

**URL:** <https://community.interop.io/t/code-template-wpf-window-registration/605>\
**Category:** io.Connect Desktop\
**Tags:** NET, starter-code\
**Created:** [June 19, 2026, 7:51am UTC](https://community.interop.io/t/code-template-wpf-window-registration/605 "2026-06-19T07:51:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![toni.petrov](https://yyz2.discourse-cdn.com/flex028/user_avatar/community.interop.io/toni.petrov/32/17_2.png) [@toni.petrov](https://community.interop.io/u/toni.petrov)\
**Post date:** [June 19, 2026, 7:51am UTC](https://community.interop.io/t/code-template-wpf-window-registration/605/1 "2026-06-19T07:51:43Z")

</div>

We’re starting to publish reusable code templates for common io.Connect patterns. The idea: small, self-contained snippets you can adapt to reproduce issues or test integration scenarios without stripping down your whole app. More context here: [Templates to help troubleshooting and support](https://community.interop.io/t/templates-to-help-troubleshooting-and-support/592)

## Minimal WPF Window snippet

Registers a WPF window as an io.Connect tab window with Channel support and a TextBox for testing keyboard input:

```csharp
var view = new Window
{
    Width = 250,
    Height = 250
};

var panel = new StackPanel { Orientation = System.Windows.Controls.Orientation.Vertical, Margin = new Thickness(10) };
panel.Children.Add(new TextBox { Text = "Dynamic TextBox", Margin = new Thickness(5) });
view.Content = panel;

await glue_.GlueWindows.RegisterWindow(view,
    new GlueWindowOptions().WithTitle("MyWindow").WithType(GlueWindowType.Tab).WithChannelSupport(true)
        .WithPlacement(new GlueWindowScreenPlacement
        {
            Bounds = new GlueWindowBounds(700, 10, 300, 300)
        }));

```

## Registering WPF Apps via the App Manager

If you’re using `RegisterWPFAppAsync` to register WPF child windows as io.Connect apps (for Layout persistence, launcher visibility, etc.), enable message forwarding via the window options modifier:

```csharp
glue_.AppManager.RegisterWPFAppAsync<WpfApp, MyWpfState, MyWpfContext>(builder =>
    builder.WithTitle("WPF in WinForms")
        .WithWindowOptionsModifier(gwo => gwo.WithWPFMessageForwarding(true)));

```

## Focus Tracking

If you need to track which io.Connect window has focus (e.g. as a workaround for `Form.ActiveForm` being `null` after embedding in io.Connect), subscribe to `WindowFocusChangedEvent`:

```csharp
glue42_.GlueWindows.SubscribeEvents<WindowFocusChangedEvent>(((@event, descriptor) =>
{
    Debug.WriteLine($"{(@event.Data ? "got" : "lost")} focus: {@event.WindowId}");
}));

```

## Docs

- [Window Management .NET API](https://docs.interop.io/desktop/capabilities/windows/window-management/net/index.html) — `RegisterWindow`, `RegisterStartupWindow`, window options
- [Channels .NET API](https://docs.interop.io/desktop/capabilities/data-sharing/channels/net/index.html) — `WithChannelSupport`, Channel Selector
- [App Management .NET API](https://docs.interop.io/desktop/capabilities/app-management/net/index.html) — `RegisterWPFAppAsync`, multi-window apps
- [Interop-Enable .NET Apps](https://docs.interop.io/desktop/getting-started/how-to/interop-enable-your-apps/net/index.html) — initialization, NuGet setup
- [.NET Examples on GitHub](https://github.com/InteropIO/net-examples) — full sample projects

More templates coming. Let us know what scenarios you’d want next.
