i have this situation. In the ShellView i have two datapicker:
<DatePicker Grid.Column="0" Margin="8" Padding="5" x:Name="from"/>
<DatePicker Grid.Column="1" Margin="8" Padding="5" x:Name="to"/>
and a button
<Button Grid.Row="2" cal:Message.Attach="[Action RunOtherView($dataContext)]" Content="Go" Margin="8" HorizontalAlignment="Center"/>
I would like that when i choose the two dates, and after press the button, the two dates will be passed in the SecondViewModel for example in my case in List Parameters. But in the constructor of SecondViewModel the "Parameters" is always null. Where is the error? How can I pass these parameters from one screen to another? Thanks
public class ShellViewModel : Conductor<IScreen>.Collection.OneActive, IShell
{
protected override void OnActivate()
{
base.OnActivate();
ActivateItem(IoC.Get<IMainViewModel>());
}
public void RunOtherView()
{
var crvm = IoC.Get<ISecondViewModel>();
crvm.Parameters = new List<DateTime>();
crvm.Parameters.Add((DateTime)d.from);
crvm.Parameters.Add((DateTime)d.to);
ActivateItem(crvm);
}
}
public class MainViewModel : Screen, IMainViewModel
{
public DateTime? from { get; set; }
public DateTime? to { get; set; }
}
public class SecondViewModel : Screen, ISecondViewModel
{
public List<DateTime> Parameters { get; set; }
protected override void OnActivate()
{
base.OnActivate();
}
public SecondViewModel()
{
//Parameters is always null
PersonalList = CollectionViewSource.GetDefaultView(Db.UpdateInformation(Parameters));
}
public override void TryClose(bool? dialogResult)
{
TryClose(dialogResult);
}
}