Ads Top

Title Notification in Windows Applications

Its time to learn some stuff about notifications. We often see notifications on our windows icons these are useful but we do not focus them because we do not know much about then, now it's time to learn something we already know. Today we are going to learn how can we make our own notifications.

Make a new windows store project and name it as "Notification Preparation" we are using plural because all of the notification types we will use the same project.

in MianPage.xaml make a button  and write the following code

 <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">      
            <Button Content="Tile button" Click="Button_Click"/>    
    </Grid>


Now open MainPage.xaml.cs and you will see that a click event for button has been generated write following code in that

 private void Button_Click(object sender, RoutedEventArgs e)
        {
            XmlDocument squareTile = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Text01);
            string xml = squareTile.GetXml();
            var textTags = squareTile.GetElementsByTagName("text");
            textTags[0].InnerText = "Heaging";
            textTags[1].InnerText = "Line one";
            textTags[2].InnerText="Line two";

            TileNotification tile = new TileNotification(squareTile);
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tile);

        }

After writing this code you may seem that some of the will not blue, the reason behind this is that you are missing some of the system file here is the image and the code you can past the code too

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Data.Xml.Dom;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Notifications;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

Before you run the app make some changes in open Package.appxmanifest from solution explorer in Application tab go to Notification and make Toast Capable form no to yes



Now everything is fine all you need is just run you application press F5 and you will see your notifications.
If you are not getting this you app on start follow the following steps

Now you will get your app's icon on start and you will be able to see the notifications.
Please try to write the code with your hands the code here is provided only for your learning. In case of any query you can message me fb.com/TalhaMSP 

No comments:

Powered by Blogger.