5

I created a WpfApplication in C# (with Visual Studio Community 2015) and i'd like to send some windows 10 notifications. I think that I'm supposed to use "ToastContent" then add it into a "ToastNotification",...

I've add "Microsoft.Toolkit.Uwp.Notification" but I can't add "Microsoft.Toolkit.Uwp.UI" (that I think is needed to display the notification). It says :

Could not install package 'Microsoft.Toolkit.Uwp 1.2.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.6', but the package does not contain any assembly references or content files that are compatible with that framework.

What can I do to install this package ? Or is there another solution to launch a windows 10 notification ?

Thank you :)

6
  • are you creating Universal Windows App or just regular WPF app? Commented Dec 28, 2016 at 11:19
  • It is a regular WPF app : File > New > Project > Templates/Visual C#/Windows/Classic Desktop > WPF Application. Commented Dec 28, 2016 at 11:23
  • then I think you can't use Universal Windows' reference (Microsoft.Toolkit.Uwp) in such project. Commented Dec 28, 2016 at 11:25
  • I think it's somehow possible and that's why i'm supposed to use Microsoft.Toolkit.UI instead of Windows.UI Commented Dec 28, 2016 at 11:28
  • Possible duplicate of WPF Desktop App, Windows 10 Notification Toast 2016 (UWP Community Toolkit) Commented Dec 28, 2016 at 11:37

1 Answer 1

4

Ok, after a few hours of searching, this is kind of easy...

Step 1 : Unload the projet then add to the first property group this element : <targetplatformversion>10.0</targetplatformversion>

Step 2 : Reload the projet

Step 3 : Add references to your project "Windows > Core > Windows.Data & Windows.UI"

Step 4 :

string xml = $@" <toast> <visual> <binding template='ToastGeneric'> <text>Some title</text> <text>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</text> </binding> </visual> </toast>"; XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); var toast = new ToastNotification(doc); ToastNotificationManager.CreateToastNotifier("ToastDesktop").Show(toast); 

Enjoy :) !

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.