There’s FVector2D UWidget::GetDesiredSize() method, but I’ve never used it myself, in code, plus, if you need to get some coordinates inside of your Canvas panel, you’ll have to keep in mind DPI scale of your viewport.
I recently moved all of my widgets to blueprints because of many troubles in handling them inside code. But fortunately in my project it was possible.