Reputation: 75
I have this data in code behind
public partial class PruebaPage : ContentPage
{
public string Datas { get; set; } // data that I want to access
and this is my View Model
namespace PuebasTemplate.ViewModels
{
public class PruebaViewModel : INotifyPropertyChanged
Is there some way to access public string Datas
from my MVVM PruebaViewModel
?
Upvotes: 1
Views: 458
Reputation: 61339
Is there a way? Sure. The page could pass itself into the VM via some method or property for one.
View models are not supposed to know anything about their view, certainly not the tight coupling of having an actual reference to it. Sounds like you have an XY problem; and that data should live in the view model to start with.
Upvotes: 2