magento2 – Magento 2 programmatically by adding a ViewModel to a block when creating it

I have encountered a problem when trying to create a block in a controller to the extent that I need the block created in the controller to also create an object of type ViewModel.

What I am trying to achieve, but I want to do it through the code in the controller instead of using the design file: –


My code in the controller is as follows: –


        /** @var BubAdvancedReviewBlockExpertReviewExpertReviews $block */
        $block = $layout->createBlock(BubAdvancedReviewBlockExpertReviewExpertReviews::class,null,('advanced-review-helper' => 'BubAdvancedReviewHelperBlockHelper'));

        return $this->getResponse()->setBody($block->toHtml());

Does anyone know if this can be done?

Thanks in advance