NPSMLib icon indicating copy to clipboard operation
NPSMLib copied to clipboard

SessionListChanged does not work in UWP

Open michalleptuch opened this issue 4 years ago • 2 comments

I just clone this repo and here is my MainPage.xaml.cs (modified sample):

using NPSMLib;

using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace NPSM_UWP
{
  public sealed partial class MainPage : Page
  {
    private NowPlayingSessionManager npsm;

    public MainPage()
    {
      InitializeComponent();
      npsm = new NowPlayingSessionManager();
      npsm.SessionListChanged += OnSessionListChanged;
    }

    private void OnSessionListChanged(object sender, NowPlayingSessionManagerEventArgs e)
    {
      Button_Click(null, null);
    }

    private void Button_Click(object sender, RoutedEventArgs e)
    {
      numTxt.Text = npsm.Count.ToString();
    }
  }
}

This event doesn't raise any time in pure UWP or XAML Islands in my another project.

OS: Windows 10 x64 19042.685 Visual Studio: 16.3.8 UWP targets: 19041, 18362

XAML Islands: Code: WPF and UWP Framework: .NET Core 3.0 Package and UWP targets: 19041, 18362

michalleptuch avatar Jan 11 '21 16:01 michalleptuch

Thanks, I'll check as soon as possible.

ADeltaX avatar Jan 14 '21 04:01 ADeltaX

After quite some tests, it seems that Windows 10 does not permit callbacks: UWP -> NPSM is ok NPSM -> UWP is not

One thing I wasn't able to repro was the XAML Islands part. In theory it should work just fine because it's running in full trust.

I'll keep this issue open until I either find a possible fix or if it's impossible.

ADeltaX avatar Jan 24 '21 15:01 ADeltaX