This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class IoC { | |
/// <summary> | |
/// Gets an instance by type and key. | |
/// </summary> | |
public static Func<Type, string, object> GetInstance = (service, key) => { throw new InvalidOperationException("IoC is not initialized."); }; | |
/// <summary> | |
/// Gets all instances of a particular type. | |
/// </summary> | |
public static Func<Type, IEnumerable<object>> GetAllInstances = service => { throw new InvalidOperationException("IoC is not initialized."); }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class IoC { | |
/// <summary> | |
/// Gets an instance by type and key. | |
/// </summary> | |
public static Func<Type, string, object> GetInstance = (service, key) => { throw new InvalidOperationException("IoC is not initialized."); }; | |
/// <summary> | |
/// Gets all instances of a particular type. | |
/// </summary> | |
public static Func<Type, IEnumerable<object>> GetAllInstances = service => { throw new InvalidOperationException("IoC is not initialized."); }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static Func<Type, Type> _defaultViewTypeToViewModelTypeResolver = | |
viewType => | |
{ | |
var viewName = viewType.FullName; | |
viewName = viewName.Replace(".Views.", ".ViewModels."); | |
var viewAssemblyName = viewType.GetTypeInfo().Assembly.FullName; | |
var suffix = viewName.EndsWith("View") ? "Model" : "ViewModel"; | |
var viewModelName = String.Format(CultureInfo.InvariantCulture, "{0}{1}, {2}", viewName, suffix, viewAssemblyName); | |
return Type.GetType(viewModelName); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void Bind(object view, object viewModel) | |
{ | |
FrameworkElement element = view as FrameworkElement; | |
if (element != null) | |
element.DataContext = viewModel; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--MainView.xaml | |
<UserControl x:Name="MainView"/> | |
--SubView.xaml | |
<UserControl x:Name="SubView"/> | |
--SubSubView.xaml | |
<UserControl x:Name="SubSubView"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ContentControl DockPanel.Dock="Top" regions:RegionManager.RegionName="Toolbar"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ContentControl regions:RegionManager.RegionName="Toolbar"/> | |
<ItemsControl regions:RegionManager.RegionName="Names"/> | |
<TabControl regions.RegionManager.RegionName="TabControl"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<DockPanel LastChildFill="True"> | |
<ContentControl DockPanel.Dock="Top" regions:RegionManager.RegionName="Toolbar"></ContentControl> | |
<ItemsControl DockPanel.Dock="Left" regions:RegionManager.RegionName="Navigation"></ItemsControl> | |
<TabControl regions:RegionManager.RegionName="Tabs"></TabControl> | |
</DockPanel> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Configures the default region adapter mappings to use in the application, in order | |
/// to adapt UI controls defined in XAML to use a region and register it automatically. | |
/// May be overwritten in a derived class to add specific mappings required by the application. | |
/// </summary> | |
/// <returns>The <see cref="RegionAdapterMappings"/> instance containing all the mappings.</returns> | |
protected virtual RegionAdapterMappings ConfigureRegionAdapterMappings() | |
{ | |
RegionAdapterMappings regionAdapterMappings = ServiceLocator.Current.GetInstance<RegionAdapterMappings>(); | |
if (regionAdapterMappings != null) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void InnerAdd(object view, string viewName, IRegionManager scopedRegionManager) | |
{ | |
if (this.ItemMetadataCollection.FirstOrDefault(x => x.Item == view) != null) | |
{ | |
throw new InvalidOperationException(Resources.RegionViewExistsException); | |
} | |
... | |
} |
OlderNewer