Interactivity 可以在每次触发时重置弹出视图模型吗?

Can Interactivity reset popup view model every time triggered?

交互性是展示新内容的最佳方式吗Window?如果是这样,我如何 reset/re-init 我的 UserControl 的 ViewModel?因为我看到它重复使用了弹出窗口。

在您的交互请求的 ViewModel 中,应该有一个名为 属性 的通知。每次调用请求时都会设置它。在那里添加一些逻辑以清除列表框。 见下文:

public INotification Notification
{
    get
    {
        return notification;
    }
    set
    {
        if (value is ItemSelectionNotification)
        {
            notification = value as ItemSelectionNotification;
            OnPropertyChanged(() => Notification);
            //*** Add ListBox clearing code here!!
            // Maybe a call to a method -> ClearListBoxes();
        }
    }
}

这是我的 ItemSelectionNotification class 的样子,以备不时之需。

public class ItemSelectionNotification : Confirmation
{
    public ItemSelectionNotification() { }
    public ItemSelectionNotification(object payload)
    {
        Payload = payload;
    }
    public object SelectedItem { get; set; }
    public object Payload { get; } = null;
}