Skip to content

Commit

Permalink
Focus event behavior on Windows (#2758)
Browse files Browse the repository at this point in the history
* Focus event behavior on Windows

* Edits.
  • Loading branch information
davidbritch authored Jan 31, 2025
1 parent 7f005d0 commit c2fee84
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion docs/whats-new/dotnet-9.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: What's new in .NET MAUI for .NET 9
description: Learn about the new features introduced in .NET MAUI for .NET 9.
ms.date: 12/20/2024
ms.date: 01/31/2025
---

# What's new in .NET MAUI for .NET 9
Expand Down Expand Up @@ -191,6 +191,21 @@ builder.ConfigureMauiHandlers(handlers =>

In .NET MAUI 9, the <xref:Microsoft.Maui.Controls.ContentPage.HideSoftInputOnTapped> property is also supported on Mac Catalyst, as well and Android and iOS.

### Focus behavior on Windows

In .NET MAUI 8 on Windows, the <xref:Microsoft.Maui.Controls.VisualElement.Focused?displayProperty=nameWithType> event, the <xref:Microsoft.Maui.Controls.VisualElement.Unfocused?displayProperty=nameWithType> event, and the <xref:Microsoft.Maui.Controls.VisualElement.IsFocused?displayProperty=nameWithType> property are applied to an element and its children:

```xaml
<VerticalStackLayout Focus="OnFocused">
<Entry />
<Editor />
</VerticalStackLayout>
```

In this example on .NET 8, the `OnFocused` event handler is executed on Windows when the <xref:Microsoft.Maui.Controls.VerticalStackLayout>, <xref:Microsoft.Maui.Controls.Entry>, or <xref:Microsoft.Maui.Controls.Editor> gains focus.

.NET MAUI 9 changes this behavior on Windows to be identical to the other platforms. Therefore, the <xref:Microsoft.Maui.Controls.VisualElement.Focused?displayProperty=nameWithType> event, the <xref:Microsoft.Maui.Controls.VisualElement.Unfocused?displayProperty=nameWithType> event, and the <xref:Microsoft.Maui.Controls.VisualElement.IsFocused?displayProperty=nameWithType> property only apply to an element. Therefore, when the previous example runs on .NET 9, the `OnFocused` event handler isn't executed because only input controls can gain focus.

### Soft keyboard input support

.NET MAUI 9 adds new soft keyboard input support for `Password`, `Date`, and `Time`. These can be enabled on <xref:Microsoft.Maui.Controls.Editor> and <xref:Microsoft.Maui.Controls.Entry> controls:
Expand Down

0 comments on commit c2fee84

Please sign in to comment.