Feature Support - Toast Notifications with ability to add controls to it

Shreyas J 21 Reputation points
2021-07-21T13:28:28.533+00:00

Hi Microsoft Team,

Is it possible to get the Toast Notification with Buttons, ComboBox or other controls which can be added to it?

Until Now, the Toast Notification has not seen any improvement in WPF and its stayed the same like in WinForms.

Thanks and Regards

Shreyas

Developer technologies Windows Presentation Foundation
0 comments No comments
{count} votes

Accepted answer
  1. Hui Liu-MSFT 48,676 Reputation points Microsoft External Staff
    2021-07-23T03:06:00.153+00:00

    For using Toast Notifications in WPF controls, we can install the WPFNotification package using NuGet . When it is installed, it will automatically add assembly references and modify the App.xaml file for you.
    The code of App.xaml is as follows:

    <ResourceDictionary>  
          <ResourceDictionary.MergedDictionaries>  
            <ResourceDictionary Source="/WPFNotification;component/Assets/NotificationUI.xaml" />  
          </ResourceDictionary.MergedDictionaries>  
    </ResourceDictionary>  
    

    An example of button display notification is as follows.
    The code of xaml is as follows:

    <Grid>  
            <Button Content="Button" HorizontalAlignment="Left" Margin="285,193,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click"/>  
    </Grid>  
    

    The code of xaml.cs is as follows:

    private void Button_Click(object sender, RoutedEventArgs e)  
        {  
          INotificationDialogService _dailogService = new NotificationDialogService();  
          var newNotification = new Notification()  
          {  
            Title = "Machine error",  
            Message = "Error!! Please check your Machine Code and Try Again"  
          };  
          _dailogService.ShowNotificationWindow(newNotification);  
        }  
    

    The result is shown in the figure:

    117258-1.gif


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.