示例#1
0
        /// <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 InvalidOperationException(
                          string.Format("No view was found for {0}. See the log for searched views.", viewModelType.FullName));
            }

            return(navigationService.Navigate(viewType, parameter));
        }
示例#3
0
        /// <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 WINDOWS_UWP
            // 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
        }