I am trying to overwrite a core template and add my custom logic using a viewModel as follows:
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="name.of.the.core.block" template="Vendor_CustomModule::path/to/template.phtml">
<arguments>
<argument name="viewModel" xsi:type="object">Vendor\CustomModule\ViewModel\Class</argument>
</arguments>
</referenceBlock>
</body>
But it's not working.
I know it is possible to inject viewModels into blocks but not sure if it is possible by referencing an existing block?