Search code examples
xamlprismprism-5

Prism NotificationRequest focus on OK button


I am using Prism 5 and I show a modal dialog via NotificationRequest. I want the focus set in the OK button, so the user can just press Enter to skip de message (now it works with Tab -> Tab -> Enter). I have tried many ways, but no one is working:

<i:Interaction.Triggers>
    <prism:InteractionRequestTrigger SourceObject="{Binding NotificationRequest, Mode=OneWay}">
        <prism:PopupWindowAction IsModal="True" CenterOverAssociatedObject="True" FocusManager.FocusedElement="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.OKButton}"/>
    </prism:InteractionRequestTrigger>
</i:Interaction.Triggers>

Of course the dialog is showing and there are no errors. The only trouble is the focus in the button.

How can I get this behaviour? What I want is the user press the enter key and the PopupWindow closes as if the button were clicked.


Solution

  • Good catch! Please submit this as an issue here: https://github.com/PrismLibrary/Prism/issues

    We will get this fixed with the next update.

    Until then, you would have to use a custom window dialog. Check out this sample to learn how to do that.

    https://github.com/PrismLibrary/Prism-Samples-Wpf/tree/master/InteractivityQuickstart

    Check out the custom popup view: https://github.com/PrismLibrary/Prism-Samples-Wpf/blob/master/InteractivityQuickstart/InteractivityQuickstart/Views/CustomPopupView.xaml