如何使用 devexpress mvvm 在按钮中显示徽章通知?

How can i show a badge notification in a button using devexpress mvvm ?

Notification Button

我想为该按钮添加徽章通知,使用 Devexpress MVVM 架构

有两种可能的方法可以完成您描述的任务。

简单(预定义徽章):
在 ViewModel 端创建 ShowXXX 属性 并将此 属性 绑定到之前在 WinForms 设计器中创建和设计的特定徽章的 Badge.Visible 属性:

// ViewModel side
public class ViewModel {
    public virtual bool ShowAlarm { get; set; }
}
...
// View side
var fluent = mvvmContext.OfType<ViewModel>();
fluent.SetBinding(alarmBadge, b => b.Visible, x => x.ShowAlarm);

复杂(对于动态生成的徽章):

如果您 运行 使用这种方式遇到麻烦,请创建 INotificationService based on the AdornerUIManager's component API. This way requires some coding, but allows you to handle any scenarios. I suggest you contact the DevExpress support directly 的自定义实现。