Certaines API Windows sont supprimées

Les API suivantes ont été supprimées :

  • ÉvénementMicrosoft.Maui.ApplicationModel.IWindowStateManager.ActiveWindowDisplayChanged
  • Méthode Microsoft.Maui.ApplicationModel.IWindowStateManager.OnWindowMessage(System.IntPtr,uint,System.IntPtr,System.IntPtr)
  • Méthode Microsoft.Maui.ApplicationModel.Platform.OnWindowMessage(System.IntPtr,uint,System.IntPtr,System.IntPtr)

Version introduite

.NET 7

Comportement précédent

Auparavant, la méthode IWindowStateManager.OnWindowMessage() était un détail d’implémentation qui exécutait une vérification des paramètres pour déterminer si l’événement ActiveWindowDisplayChanged devait être déclenché. L’événement ActiveWindowDisplayChanged peut être appelé si le type concret a pu observer les modifications de l’affichage contenant la fenêtre actuellement active.

Vous pouvez appeler la méthode Platform.OnWindowMessage() pour passer des messages. Cette méthode appelait IWindowStateManager.OnWindowMessage(), puis qui entraînait éventuellement le déclenchement de l’événement ActiveWindowDisplayChanged.

Nouveau comportement

Les API sont maintenant supprimées.

Type de changement cassant

Cette modification peut affecter la compatibilité binaire et la compatibilité des sources.

Raison de la modification

L’événement ActiveWindowDisplayChanged n’aurait jamais dû être public, car il s’agissait d’un détail de mise en œuvre et ne fournissait aucune information supplémentaire indiquant que « quelque chose avait changé ». Nous l’avons supprimé pour éviter toute confusion avec l’événement MainDisplayInfoChanged et réduire la complexité de l’implémentation potentielle pour les utilisateurs et le SDK lui-même.

La méthode IWindowStateManager.OnWindowMessage() était également un détail d’implémentation et n’aurait jamais dû être publique. Cette API ne fait plus rien et a donc été supprimée.

La méthode Platform.OnWindowMessage() a été implémentée pour contourner une limitation de Xamarin.Forms et Xamarin.Essentials. Elle a été introduite dans .NET MAUI pour faciliter la migration, et utilisée dans .NET 6. Toutefois, dans .NET 7, cette API ne fait plus rien et a été supprimée.

  • Si vous ne générez pas votre application pour Windows, aucune action n’est nécessaire.
  • Si vous utilisiez ActiveWindowDisplayChanged, utilisez plutôt Microsoft.Maui.Devices.DeviceDisplay.Current.MainDisplayInfoChanged.
  • Si vous appeliez l’une des méthodes OnWindowMessage(), supprimez l’appel.

API affectées

  • Microsoft.Maui.ApplicationModel.IWindowStateManager.ActiveWindowDisplayChanged
  • Microsoft.Maui.ApplicationModel.IWindowStateManager.OnWindowMessage(System.IntPtr,uint,System.IntPtr,System.IntPtr)
  • Microsoft.Maui.ApplicationModel.Platform.OnWindowMessage(System.IntPtr,uint,System.IntPtr,System.IntPtr)