How to use uwp-uri in WPF app?

仁秀 付 1 Reputation point
2021-08-09T10:32:31.503+00:00

My WPF app needs notification of win10 style , so I used Microsoft.Toolkit.Uwp.Notifications --NuGet package. But the picture of AppLogoOverride cannot be replaced ,because the schema of AppLogoOverride Uri only 3 types( http:// ms-appx:///
ms-appdata:///) can be used. How to use uwp-uri in WPF app? Or how to replace the picture of AppLogoOverride in another way?
Excuse me ,I’m not good at English .

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,676 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Hui Liu-MSFT 40,266 Reputation points Microsoft Vendor
    2021-08-12T05:35:19.29+00:00

    I created Wpf Application (.Net Core 3.1) and downloaded and installed the package Microsoft.Toolkit.Uwp.Notifications.Then I use the following code to display the Notification with picture. You could refer to the following code.
    The code of xaml:

    <Grid>  
            <Button Click="Button_Click" Width="100" Height="80">click</Button>  
    </Grid>  
    

    The code of xaml.cs(Button):

      private void Button_Click(object sender, RoutedEventArgs e)  
            {  
              new ToastContentBuilder().AddArgument("action", "viewConversation")  
        .AddArgument("conversationId", 9813)  
        .AddText("Ev2 Compiler Library")  
        .AddText("Allow sending build Data to Microsoft")  
        .AddAppLogoOverride(new Uri(@"C:\Users\userName\Desktop\3.jpg"), ToastGenericAppLogoCrop.Default)  
        .Show();  
            }  
    

    The result is shown in the picture:
    122499-pastedimage.png


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.