Reputation: 51
I am setting command in my model as follow
Settings test = new Settings();
private Command _navigate;
public Command Navigate
{
set { SetProperty(ref _navigate, value); }
get { return _navigate; }
}
then I am adding it to my collection
private void LoadGeneralSetting()
{
foreach ( var setting in _customSettings.GeneralSettings )
{
var detail = new Settings()
{
Type = setting.Type,
Index = setting.Index,
IsSelected = setting.Value,
Navigate = new Command(GeneralSettingNavigation(null))
};
GeneralSetting.Add(detail);
}
}
and then the method
private void GeneralSettingNavigation(object sender)
{
Application.Current.MainPage.Navigation.PushAsync(new ThemeSelection());
}
however I am getting underline "Cannot resolve constructor 'Command(void)', candidates are: Command(System.Action) (in class Command) Command(System.Action) (in class Command)"
can you please advise what am I doing wrong I have tried null setting object.. just a string but still the same outcome
Upvotes: 0
Views: 26
Reputation: 89102
that's because the constructor for Command
requires an Action
, just like the error message is telling you
Navigate = new Command(() => { GeneralSettingNavigation(null); })
Upvotes: 1