❔ Problem Binding to Image Size
I am making an app that displays a series of books. An image and title of the book is to be displayed in a listBox of the main window. So far this works well. I decided to add a slider to allow the user to choose a size for the image of the book. I bind the width and height of the image to the ViewModel and make a switch statement for the various locations of the slider to determine the size of the image.
When I start the app I run into two problems:
1. The image of each book takes up the entire width of the window OR
2. I get a System.InvalidOperationException: 'Invalid size returned for Measure.'
I believe the problem is connected to the "OnSliderChanged" method of my ViewModel. Initially, the slider is set to 0 (but my slider is between 1 and 5) and so it was throwing an exception. I end the method early if it is set to 0 and the exception thrown above is shown.
4 Replies
what is the container for this
Image
tag?
the Width and Height settings are worthless if the container doesn't respect themIt's an Avalonia Image. I can set the size no problem if I manually enter the size, but when I try to bind them it all goes weird.
okay, but what's it's container?
also, why are you using
Slider
for the switch, instead of value
?Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.