我尝试使用 XAML 图像重现 Direct2D 的 SurfaceImageSource 示例:
https://learn.microsoft.com/zh-cn/windows/uwp/gaming/directx-and-xaml-interop
我在这一行有一个编译错误:
theImage().Source(surfaceImageSource);
Source 需要对 ImageSource 的引用,但是当我提供 SurfaceImageSource 时它不会为我编译,就像示例中那样。
错误(活动)E0304 没有重载函数实例“winrt::Microsoft::UI::Xaml::Controls::Image::Source”与参数列表匹配
知道哪里出了问题吗?
最少的代码:
关于 XML 文件:
<Image x:Name="theImage" Width="500" Height="500" />
关于cpp文件
void MainWindow::myButton_Click(IInspectable const&, RoutedEventArgs const&)
{
myButton().Content(box_value(L"Clicked"));
SurfaceImageSource surfaceImageSource(500, 500);
theImage().Source(surfaceImageSource); // -> FAIL here
}