public override void ShowWindow(object rootModel, object context = null, IDictionary <string, object> settings = null) { var viewType = ViewLocator.LocateTypeForModelType(rootModel.GetType(), null, null); if (typeof(RadWindow).IsAssignableFrom(viewType) || typeof(UserControl).IsAssignableFrom(viewType)) { NavigationWindow navWindow = null; if (Application.Current != null && Application.Current.MainWindow != null) { navWindow = Application.Current.MainWindow as NavigationWindow; } if (navWindow != null) { var window = CreatePage(rootModel, context, settings); navWindow.Navigate(window); } else { CreateRadWindow(rootModel, false, context, settings).Show(); } return; } base.ShowWindow(rootModel, context, settings); }
/// <inheritdoc /> public void NavigateToViewModel(Type viewModel, object extraData = null) { var viewType = ViewLocator.LocateTypeForModelType(viewModel, null, null); var packUri = ViewLocator.DeterminePackUriFromType(viewModel, viewType); var uri = new Uri(packUri, UriKind.Relative); frame.Navigate(uri, extraData); }
/// <summary> /// Navigate to the specified model type. /// </summary> /// <param name="navigationService">The navigation service.</param> /// <param name="viewModelType">The model type to navigate to.</param> /// <param name="parameter">The object parameter to pass to the target.</param> /// <returns>Whether or not navigation succeeded.</returns> public static bool NavigateToViewModel(this INavigationService navigationService, Type viewModelType, object parameter = null) { var viewType = ViewLocator.LocateTypeForModelType(viewModelType, null, null); if (viewType == null) { throw new Exception(string.Format("No view was found for {0}. See the log for searched views.", viewModelType.FullName)); } return(navigationService.Navigate(viewType, parameter)); }
/// <summary> /// Builds the URI. /// </summary> /// <returns>A uri constructed with the current configuration information.</returns> public Uri BuildUri() { var viewType = ViewLocator.LocateTypeForModelType(typeof(TViewModel), null, null); if (viewType == null) { throw new InvalidOperationException(string.Format("No view was found for {0}. See the log for searched views.", typeof(TViewModel).FullName)); } var packUri = ViewLocator.DeterminePackUriFromType(typeof(TViewModel), viewType); var qs = BuildQueryString(); return(new Uri(packUri + qs, UriKind.Relative)); }
public override bool?ShowDialog(object rootModel, object context = null, IDictionary <string, object> settings = null) { var viewType = ViewLocator.LocateTypeForModelType(rootModel.GetType(), null, null); if (typeof(RadWindow).IsAssignableFrom(viewType) || typeof(UserControl).IsAssignableFrom(viewType)) { var radWindow = CreateRadWindow(rootModel, true, context, settings); radWindow.ShowDialog(); return(radWindow.DialogResult); } return(base.ShowDialog(rootModel, context, settings)); }
/// <summary> /// Builds the URI. /// </summary> /// <returns>A uri constructed with the current configuration information.</returns> public Uri BuildUri() { var viewType = ViewLocator.LocateTypeForModelType(typeof(TViewModel), null, null); if (viewType == null) { throw new InvalidOperationException(string.Format("No view was found for {0}. See the log for searched views.", typeof(TViewModel).FullName)); } var packUri = ViewLocator.DeterminePackUriFromType(typeof(TViewModel), viewType); var qs = BuildQueryString(); #if WinRT // We need a value uri here otherwise there are problems using uri as a parameter return(new Uri("caliburn://" + packUri + qs, UriKind.Absolute)); #else return(new Uri(packUri + qs, UriKind.Relative)); #endif }
string DeterminePageName() { var page = ViewLocator.LocateTypeForModelType(typeof(TViewModel), null, null); if (page == null) { throw new Exception(string.Format("No view was found for {0}. See the log for searched views.", typeof(TViewModel).FullName)); } var pageAssemblyName = GetAssemblyName(page.Assembly); var pageName = page.FullName.Replace(pageAssemblyName, "").Replace(".", "/") + ".xaml"; if (!entryAssemblyName.Equals(pageAssemblyName)) { return("/" + pageAssemblyName + ";component" + pageName); } return(pageName); }