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

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,777 questions
0 comments No comments
{count} votes

Accepted answer
  1. Hui Liu-MSFT 48,541 Reputation points Microsoft Vendor
    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.