<Image Name="ImageDisplay"
Source="{Binding CurrentImage}"
Grid.Column="1"/>
public class NewWindowViewModel : ViewModelBase, INotifyPropertyChanged
{
public Bitmap CurrentImage = new Bitmap(Path.Combine(Environment.CurrentDirectory, @"Assets\LOGO.png"));
}
public NewWindow()
{
InitializeComponent();
_viewModel = new NewWindowViewModel();
DataContext = _viewModel;
#if DEBUG
this.AttachDevTools();
#endif
}
Image is not displayed, output returns error: [Binding] Error in binding to 'Avalonia.Controls.Image'.'Source': 'Could not find a matching property accessor for 'CurrentImage' on 'RandomProject.ViewModels.NewWindowViewModel''
Everything should be working fine, except it doesn't. I'm new to Avalonia, I wanted to free myself from being limited only to Windows, but my first impressions are not exactly good.
There is official documentation here https://docs.avaloniaui.net/docs/controls/image, but its FULL of errors. Not exactly helpful when your project won't even build.
CodePudding user response:
You need to define a getter method for this property also.
public Bitmap getCurrentImage()
{
return CurrentImage;
}