public IRangeModel ShowRangeDialog(double from, double to) { RangeViewModel rangeVM = new RangeViewModel(from, to); rangeVM.Auto = double.IsNaN(from) || double.IsNaN(to); var dlg = new RangeForm(rangeVM); if (dlg.ShowDialog() == true) { return(rangeVM); } else { return(null); } }
public RangeForm(RangeViewModel viewModel) { InitializeComponent(); this.viewModel = viewModel; //Do this if you need access to the VM from inside your View. Or you could just use this.Datacontext to access the VM. this.DataContext = viewModel; }