Wpf Prism如何设置自定义弹出窗口的WindowStartupLocation

时间:2016-03-28 14:15:44

标签: c# wpf prism

我已使用此guide使用Prism交互功能成功实现了自定义弹出窗口。

<i:Interaction.Triggers>
    <prism:InteractionRequestTrigger SourceObject="{Binding CustomPopupViewRequest, Mode=OneWay}">
        <prism:PopupWindowAction>
            <prism:PopupWindowAction.WindowContent>
                <local:PurchasePaymentInfoView />
            </prism:PopupWindowAction.WindowContent>
        </prism:PopupWindowAction>
    </prism:InteractionRequestTrigger>
</i:Interaction.Triggers>

但弹出窗口显示在屏幕上的随机位置。我想定义此弹出窗口的WindowStartupLocationCenterScreen

1 个答案:

答案 0 :(得分:2)

如果您使用的是最新的预发布版,则可以使用int属性。

https://github.com/PrismLibrary/Prism/blob/master/Source/Wpf/Prism.Wpf/Interactivity/PopupWindowAction.cs#L50

如果您不是,并且使用当前的function reqApis(call, callback){ request(call, callback); } function reqTokenCallback( err, response, body) { if (response.statusCode === 200) { reqApis(callApiA, reqApiCallback); } else { res.redirect('/'); } } function reqApiCallback( err, response, body ) { if (response.statusCode === 200) { res.json(body); } else if (body.invalidToken) { if (refresh token still exist) { reqApis(callRefreshToken, reqTokenCallback); } else { res.redirect('/login'); } } else { response.json('Unknown error'); } } reqApis(callApiA, reqApiCallback); 属性将无法满足您的需求:

https://github.com/PrismLibrary/Prism/blob/master/Source/Wpf/Prism.Wpf/Interactivity/PopupWindowAction.cs#L40

然后您必须创建自己的WindowStartupLocation