Magento 2 How to pass data from Controller to Block

I need to send data from controller to Block, I have used many ways but it does not work.
I’m trying this way:


public function execute()

       $order_id = $this->getRequest()->getParam("order_id");
       $order = $this->orderInterface->loadByIncrementId($order_id);
       $pakkeShipment = $order->getPakkeShipment();

        $resultPage = $this->resultPageFactory->create();
        $resultPage->getConfig()->getTitle()->prepend(__(' heading '));

        $block = $resultPage->getLayout()



class TrackingInfo extends Template
    public $trackingData;

    public function __construct(
        TemplateContext $context,
        array $data = []
    ) {
        parent::__construct($context, $data);

    public function setTrackingInfo($trackingData){
        $this->trackingData = $trackingData;

    public function getTrackingInfo(){
        return $this->trackingData;


< ?xml version="1.0"?>


I get an error in this way, I just want to send $pakkeShipment to setTrackingInfo() so I can use the method getTrackingInfo(); in my phtml.