Set UMG ViewModel for UUserWidget C++

I try to implement new MVVM system into my project, but have a problem. In documentation for Manual ViewModel Creation Type says, that:

The Manual creation method requires you to create an instance of the Viewmodel yourself somewhere in your application’s code, then assign it to the widget manually. The widget has a Viewmodel object reference, but it will have a null value until you assign a Viewmodel to it.

As i understand, i can set Viemodel into my .cpp file of my UUserWidget class or in Blueprint, but i didnt find any functions for this in c++, is it possible? Thanks!

It seems those functions are created dynamically. I noticed this in the UMG Designer:

And then peaking in the C++ code for the plugin,

Apologies for necro-ing this post again, but since it’s one of the first results on google, putting this here for future-me:

The system uses userwidget extensions.

if (UMVVMView* view = Cast<UMVVMView>(userWidget->GetExtension(UMVVMView::StaticClass())))
{
	FName vmName("MyViewModel");
	if (view->GetViewModel(vmName) == nullptr)
	{
		view->SetViewModel(vmName, LifeTime);
	}
}