Hi! I have the very basic case, but can't find elegant solution: need to know original image size for layout. But after loading an image to Image
view I get -1
value for its width and height.
Here's a code sample, what I'm trying:
var icon = new Image {
Source = ImageSource.FromFile("icon-edit.png")
};
// This will output -1 values for width and width request
Console.WriteLine("Width={0}, WidthRequest={1}", icon.Width, icon.WidthRequest);
// Adding to relative layout, won't work as expected! Icon's width is calculated as -1.
Children.Add(editIcon,
Constraint.RelativeToParent((parent) => (parent.Width - icon.Width) / 2),
Constraint.Constant(10)
);
In the example above icon should be centered horizontally and I could achieve that in some other way. But actually I'll need more sophisticated layout, that's why I need to know image width.