I have property SettingValue in SettingsViewModel.cs located in project ExampleApp that I would like to use as setting and in case it changes, I would like to pass it as a property (DeviceName) into another Class named ServiceOne.cs that is located in another project ExampleApp.Service.
I would like to know solution without using MessagingCenter. MessagingCenter is available only for Xamarin. I want to understand how this should be done in general so I can utilize it also for example in WPF and other.
According to my research I need to create a new project with interface and use it for passing value from SettingsViewModel.cs to ServiceOne.cs? However I cant figure out how it can be done. Any hints?
SettingsViewModel.cs:
using ExampleApp.Views;
using Xamarin.Forms;
namespace ExampleApp.ViewModels
{
public class SettingsViewModel : BaseViewModel
{
public SettingsViewModel()
{
Title = "Browse";
}
private string settingValue;
public string SettingValue
{
get => this.settingValue;
set
{
this.settingValue = value;
this.OnPropertyChanged();
}
}
}
}
ServiceOne.cs:
namespace ExampleApp.Service
{
public class ServiceOne
{
public string DeviceName { get; set; }
private void OnDeviceDiscovered()
{
this.DeviceName = "";
}
}
}
Please notice also project references.
