Closed weltkante closed 8 years ago
Thanks for reporting this - we're planning to investigate various issues with Win2D integrating in the designer in the near future, and will add this to the list of things to check.
I'm not sure if this is a Win2D bug or more of a broader designer limitation. From a quick test just now, it seems that most file access APIs behave the same way - for instance File.ReadAllBytes also fails to find app resources if it is called in the designer.
It's likely that XAML is doing special things to make BitmapImage find the right data in this context, as XAML and the Visual Studio designer are tightly integrated.
Well, I'm loading images here and not arbitrary files. If you can't do the same trick BitmapImages does to load the binary file, couldn't you just instantiate a BitmapImage to leverage its workaround and then somehow initialize the Win2D image with the data?
I guess you are right, I can only get the BitmapImage loading if I actually put it into the visual tree.
Hi,
Win2D team discussed this issue but decided it isn't something we want to spend time on.
I have a feeling it may not even be possible for 3rd party code (other than XAML UI) to load resources from the app package while running in the designer. But in any case, we have other priorities and lack bandwidth to look into this.
If you are able to figure out a way to make this work and want to submit a pull request, we'd certainly be willing to accept such a contribution!
Thanks,
When using CanvasImageSource in a Win10 UWP "Custom Control" to provide a custom-rendered image brush the CanvasBitmap LoadAsync call fails when the control is loaded into the VS designer.
CanvasBitmap.LoadAsync throws an exception that it cannot find the file, but when running the project the file loads just fine.
Also when I switch to a stock BitmapImage instead of loading it with Win2D it does work in the designer:
So if BitmapImage can do it then it should be possible to get it working for Win2D and it probably is something wrong with the loading logic in CanvasBitmap.LoadAsync which makes it not work in the designer.