private Option PresentChoice(Choice choice) { ChoiceModel choiceModel = new ChoiceModel(choice); ShowModalParameter dialogParameter = new ShowModalParameter { Content = choiceModel }; // run the dialog to completion Dialog.ShowModalCommand.Execute(dialogParameter, _host); return(choiceModel.Selected); }
public void ShowModal(object sender, ExecutedRoutedEventArgs e) { // crash if incorrect parameter type ShowModalParameter parameter = (ShowModalParameter)e.Parameter; // this is the source of the event, and we will resolve DataTemplate from their position FrameworkElement host = (FrameworkElement)e.OriginalSource; // resolve the data template DataTemplate template = parameter.DataTemplate ?? (DataTemplate)host.TryFindResource(new DataTemplateKey(parameter.Content.GetType())); // display the dialog appropriate to the content ContentTemplate = template; Content = parameter.Content; ShowDialog(); }