部分 Windows API 已移除

下列 API 已遭到移除:

  • 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) 方法

導入的版本

.NET 7

先前的行為

先前,IWindowStateManager.OnWindowMessage() 方法為實作詳細資料,會對參數執行檢查,以判斷是否應引發 ActiveWindowDisplayChanged 事件。 若具體類型可在包含目前使用中視窗的顯示觀察變更,則可叫用 ActiveWindowDisplayChanged 事件。

您可以呼叫 Platform.OnWindowMessage() 方法以傳遞訊息。 此方法會呼叫 IWindowStateManager.OnWindowMessage(),而這會選擇性地引發 ActiveWindowDisplayChanged 事件。

新的行為

API 現已移除。

中斷性變更的類型

此變更可能會影響二進位相容性來源相容性

變更原因

ActiveWindowDisplayChanged 事件應永不公開,因為此事件為實作詳細資料,且不會提供「內容有所異動」的其他資訊。 我們已將其移除,以免與 MainDisplayInfoChanged 事件混淆,並降低對使用者和 SDK 本身而言,實作可能的複雜度。

IWindowStateManager.OnWindowMessage() 方法也是實作詳細資料,因此應永不公開。 此 API 不再具任何效用,因此已經移除。

Platform.OnWindowMessage() 方法已經實作,以因應 Xamarin.Forms 和 Xamarin.Essentials 的限制。 此方法已引入 .NET MAUI,以協助移轉並會用於 .NET 6。 不過此 API 在 .NET 7 中不再具任何效用,因此已經移除。

  • 若您並非建置適用於 Windows 的應用程式,則無需採取任何動作。
  • 若您使用的是 ActiveWindowDisplayChanged,請改為使用 Microsoft.Maui.Devices.DeviceDisplay.Current.MainDisplayInfoChanged
  • 若您呼叫了任一 OnWindowMessage() 方法,請移除該呼叫。

受影響的 API

  • 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)