Search code examples
c#windows-phone-8live-tilebackground-agents

Windows phone background agent ShellTile can't be added


I'm using this code to push notifications:

        protected override void OnInvoke(ScheduledTask task)
        {
            //TODO: Add code to perform your task in background

            string toastMessage = "Periodic task running.";

            ShellToast toast = new ShellToast();
            toast.Title = "Background Agent Sample";
            toast.Content = toastMessage;
            toast.Show();




#if DEBUG
            ScheduledActionService.LaunchForTest(
                task.Name, TimeSpan.FromSeconds(30));
#endif


            NotifyComplete();
        }

The shell toast works great. The problem is that when I use

ShellTile tile = Shelltilve.ActiveTiles.First();

I can't find the First Method.

I'm using a Windows Phone 8 if that helps. I searched and I found that it works, but haven't been able to do it with my code.


Solution

  • Have you added

    using System.Linq;
    

    to your code file?