Button documentation shows wrong Bitmap creation in xaml
ylatuya opened this issue · 4 comments
ylatuya commented
Describe the bug
Adding a Bitmap to Resources following the example https://docs.avaloniaui.net/docs/controls/button#play-button ends with a compilation error
<Application.Resources>
<Bitmap x:key="Play">/Assets/Player/Play.png</Bitmap>
<Bitmap x:key="Pause">/Assets/Player/Pause.png</Bitmap>
</Application.Resources>
App.axaml(30,30): Error XAMLIL: No Content property or any Add methods found for type Avalonia.Visuals:Avalonia.Media.Imaging.Bitmap Line 13, position 30. (XAMLIL)
To Reproduce
Steps to reproduce the behavior:
- Follow the linked documentation example
- Build
- See compilation error
Expected behavior
The XAML translates to:
var assets = AvaloniaLocator.Current.GetService<IAssetLoader>()!;
Resources["Play"] = new Bitmap(assets.Open(new Uri("/Assets/Player/play.png")));
Additional context
Avalonia 1.10.13
maxkatz6 commented
Wrong syntax. Bitmap needs a ctor parameter.
See AvaloniaUI/Avalonia#5659 (comment) how to do so
ylatuya commented
Thanks. Should I create a new PR to update the documentation?
maxkatz6 commented
Yes, documentation is wrong here
maxkatz6 commented