使用 AdControl 在为 UWP 打包的 WPF 应用程序中显示广告

Using AdControl to display ads in a WPF application packaged for UWP

我(似乎)已经使用以下指南成功地为我的 WPF 应用程序创建了一个 UWP 包:

https://docs.microsoft.com/en-us/windows/uwp/porting/desktop-to-uwp-packaging-dot-net

现在我想利用 AdControl class 在我的项目中显示横幅广告,详情如下:

https://docs.microsoft.com/en-us/windows/uwp/monetize/adcontrol-in-xaml-and--net

这可能吗?我没有在我的 WPF 项目的引用下看到 "Universal Windows" 部分,我猜这是因为它不是原始的通用 Windows 项目。我确实在我使用上述指南创建的 UWP 包包装器项目的参考下看到了它,但这并不能帮助我在 WPF 项目中展示广告。

感谢任何帮助。

您可以添加通用 Windows 参考并在您的项目中使用 API,如 here 所述,但您不能使用 AdControl,因为 WPF 中的 XAML/UI 不一样作为 UWP 中的 XAML 并且 AdControl 是 UWP XAML 控件:

As mentioned above, there are exceptions to the rule that Windows 10 APIs are accessible from PC software. The first big exception concerns XAML UI APIs. The XAML framework in UWP is different from the one in WPF and you really don’t want to be mixing them up, anyways.