MessagingCenter Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Caution
We recommend migrating to CommunityToolkit.MVVM.WeakReferenceMessenger
: https://www.nuget.org/packages/CommunityToolkit.Mvvm
Caution
We recommend migrating to CommunityToolkit.Mvvm.Messaging.WeakReferenceMessenger
: https://www.nuget.org/packages/CommunityToolkit.Mvvm
Associates a callback on subscribers with a specific message name.
public ref class MessagingCenter : Microsoft::Maui::Controls::IMessagingCenter
public class MessagingCenter : Microsoft.Maui.Controls.IMessagingCenter
[System.Obsolete("We recommend migrating to `CommunityToolkit.MVVM.WeakReferenceMessenger`: https://www.nuget.org/packages/CommunityToolkit.Mvvm")]
public class MessagingCenter : Microsoft.Maui.Controls.IMessagingCenter
[System.Obsolete("We recommend migrating to `CommunityToolkit.Mvvm.Messaging.WeakReferenceMessenger`: https://www.nuget.org/packages/CommunityToolkit.Mvvm")]
public class MessagingCenter : Microsoft.Maui.Controls.IMessagingCenter
type MessagingCenter = class
interface IMessagingCenter
[<System.Obsolete("We recommend migrating to `CommunityToolkit.MVVM.WeakReferenceMessenger`: https://www.nuget.org/packages/CommunityToolkit.Mvvm")>]
type MessagingCenter = class
interface IMessagingCenter
[<System.Obsolete("We recommend migrating to `CommunityToolkit.Mvvm.Messaging.WeakReferenceMessenger`: https://www.nuget.org/packages/CommunityToolkit.Mvvm")>]
type MessagingCenter = class
interface IMessagingCenter
Public Class MessagingCenter
Implements IMessagingCenter
- Inheritance
-
MessagingCenter
- Attributes
- Implements
Remarks
The following shows a simple example of a strongly-typed callback using MessagingCenter is:
public class SubscriberThing
{
public int IntProperty { get; set; }
}
var subscriber = new SubscriberThing();
MessagingCenter.Subscribe<MyPage, int> (subscriber, "IntPropertyMessage", (s, e) => {
subscriber.IntProperty = e;
});
//...later...
MessagingCenter.Send<MyPage, int>(this, "IntPropertyMessage", 2);
Assert.AreEqual(2, subscriber.IntProperty);
Constructors
MessagingCenter() |
Properties
Instance |
Gets the singleton instance of the MessagingCenter. |
Methods
Explicit Interface Implementations
Applies to
.NET MAUI
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기