Skip to content

Instantly share code, notes, and snippets.

public class SomeViewModel : INotifyPropertyChanged, INotifyDataErrorInfo
{
errorsContainer = new ErrorsContainer<string>(x => ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs(x)));
public IEnumerable GetErrors(string propertyName)
{
return errorsContainer.GetErrors(propertyName);
}
public class SomeViewModel : BindableBase
{
errorsContainer = new ErrorsContainer<string>(x => ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs(x)));
public IEnumerable GetErrors(string propertyName)
{
return errorsContainer.GetErrors(propertyName);
}
public class SampleViewModel: BindableBase, INavigationAware
{
...
private IRegionNavigationJournal journal;
public void OnNavigatedTo(NavigationContext navigationContext)
{
journal = navigationContext.NavigationService.Journal
}
-- Sending Navigation Parameters
var parameters = new NavigationParameters();
parameters.Add("SomeParamater", "SomeParameterValue");
regionManager.RequestNavigate("Navigation", "viewName", parameters);
-- Receiving Navigation Parameters
public class SampleViewModel: BindableBase, INavigationAware
{
...
public class SampleViewModel: BindableBase, INavigationAware
{
...
public const string Name = "SampleView";
public bool IsNavigationTarget(NavigationContext navigationContext)
{
return navigationContext.Uri.OriginalString.Equals(Name)? true : false
}
...
public interface INavigationAware
{
/// <summary>
/// Called when the implementer has been navigated to.
/// </summary>
/// <param name="navigationContext">The navigation context.</param>
void OnNavigatedTo(NavigationContext navigationContext);
/// <summary>
/// Called to determine if this instance can handle the navigation request.
-- Register
unityContainer.RegisterType<object, SomeView>("viewName");
unityContainer.RegisterType<object, SomeOtherView>("someOtherViewName");
-- Usage
regionManager.RequestNavigate("Navigation", "viewName");
regionManager.RequestNavigate("Navigation", "someOtherViewName");
public object LoadContent(IRegion region, NavigationContext navigationContext)
{
if (region == null)
throw new ArgumentNullException(nameof(region));
if (navigationContext == null)
throw new ArgumentNullException(nameof(navigationContext));
string candidateTargetContract = this.GetContractFromNavigationContext(navigationContext);
--xaml
<ItemsControl prism:RegionManager.RegionName="Navigation"/>
regionManager.Region[“Navigation”].Add(SomeView);
regionManager.Region[“Navigation”].Add(SomeView);
regionManager.Region[“Navigation”].Add(SomeView);
unityContainer.RegisterType<object, SomeView>("viewName");
regionManager.RequestNavigate(“Navigation”, “viewName”);
--xaml
<ItemControl prism:RegionManager.RegionName="Navigation">
regionManager.Region[“Navigation”].Add(SomeView);
unityContainer.RegisterType<object, SomeView>("viewName");
regionManager.RequestNavigate(“Navigation”, “viewName”);