diff --git a/Samples/Stylet.Samples.OverridingViewManager/App.config b/Samples/Stylet.Samples.OverridingViewManager/App.config
new file mode 100644
index 0000000..8e15646
--- /dev/null
+++ b/Samples/Stylet.Samples.OverridingViewManager/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Samples/Stylet.Samples.OverridingViewManager/App.xaml b/Samples/Stylet.Samples.OverridingViewManager/App.xaml
new file mode 100644
index 0000000..aa2422b
--- /dev/null
+++ b/Samples/Stylet.Samples.OverridingViewManager/App.xaml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/Stylet.Samples.OverridingViewManager/Bootstrapper.cs b/Samples/Stylet.Samples.OverridingViewManager/Bootstrapper.cs
new file mode 100644
index 0000000..bd1bf5e
--- /dev/null
+++ b/Samples/Stylet.Samples.OverridingViewManager/Bootstrapper.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Stylet.Samples.OverridingViewManager
+{
+ public class Bootstrapper : Bootstrapper
+ {
+ protected override void ConfigureIoC(StyletIoC.IStyletIoCBuilder builder)
+ {
+ base.ConfigureIoC(builder);
+
+ builder.Bind().To();
+ }
+ }
+}
diff --git a/Samples/Stylet.Samples.OverridingViewManager/CustomViewManager.cs b/Samples/Stylet.Samples.OverridingViewManager/CustomViewManager.cs
new file mode 100644
index 0000000..4b4b7f0
--- /dev/null
+++ b/Samples/Stylet.Samples.OverridingViewManager/CustomViewManager.cs
@@ -0,0 +1,49 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace Stylet.Samples.OverridingViewManager
+{
+ [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
+ sealed class ViewModelAttribute : Attribute
+ {
+ readonly Type viewModel;
+
+ public ViewModelAttribute(Type viewModel)
+ {
+ this.viewModel = viewModel;
+ }
+
+ public Type ViewModel
+ {
+ get { return viewModel; }
+ }
+ }
+
+ public class CustomViewManager : ViewManager
+ {
+ // Dictionary of ViewModel type -> View type
+ private Dictionary viewModelToViewMapping;
+
+ public CustomViewManager()
+ {
+ var mappings = from type in AssemblySource.Assemblies.SelectMany(x => x.GetTypes())
+ let attributes = (ViewModelAttribute[])type.GetCustomAttributes(typeof(ViewModelAttribute), false)
+ where attributes.Length == 1 && typeof(UIElement).IsAssignableFrom(type)
+ select new { View = type, ViewModel = attributes[0].ViewModel };
+
+ this.viewModelToViewMapping = mappings.ToDictionary(x => x.ViewModel, x => x.View);
+ }
+
+ public override UIElement LocateViewForModel(object model)
+ {
+ Type viewType;
+ if (!this.viewModelToViewMapping.TryGetValue(model.GetType(), out viewType))
+ throw new Exception(String.Format("Could not find View for ViewModel {0}", model.GetType().Name));
+ return (UIElement)IoC.GetInstance(viewType, null);
+ }
+ }
+}
diff --git a/Samples/Stylet.Samples.OverridingViewManager/Properties/AssemblyInfo.cs b/Samples/Stylet.Samples.OverridingViewManager/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..2a6e1ec
--- /dev/null
+++ b/Samples/Stylet.Samples.OverridingViewManager/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Stylet.Samples.OverridingViewManager")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Stylet.Samples.OverridingViewManager")]
+[assembly: AssemblyCopyright("Copyright © 2014")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+//In order to begin building localizable applications, set
+//CultureYouAreCodingWith in your .csproj file
+//inside a . For example, if you are using US english
+//in your source files, set the to en-US. Then uncomment
+//the NeutralResourceLanguage attribute below. Update the "en-US" in
+//the line below to match the UICulture setting in the project file.
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
+ //(used if a resource is not found in the page,
+ // or application resource dictionaries)
+ ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
+ //(used if a resource is not found in the page,
+ // app, or any theme specific resource dictionaries)
+)]
+
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Samples/Stylet.Samples.OverridingViewManager/Properties/Resources.Designer.cs b/Samples/Stylet.Samples.OverridingViewManager/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..5c00f16
--- /dev/null
+++ b/Samples/Stylet.Samples.OverridingViewManager/Properties/Resources.Designer.cs
@@ -0,0 +1,71 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.18444
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace Stylet.Samples.OverridingViewManager.Properties
+{
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Stylet.Samples.OverridingViewManager.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/Samples/Stylet.Samples.OverridingViewManager/Properties/Resources.resx b/Samples/Stylet.Samples.OverridingViewManager/Properties/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/Samples/Stylet.Samples.OverridingViewManager/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Samples/Stylet.Samples.OverridingViewManager/Properties/Settings.Designer.cs b/Samples/Stylet.Samples.OverridingViewManager/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..ea9af1f
--- /dev/null
+++ b/Samples/Stylet.Samples.OverridingViewManager/Properties/Settings.Designer.cs
@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.18444
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace Stylet.Samples.OverridingViewManager.Properties
+{
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/Samples/Stylet.Samples.OverridingViewManager/Properties/Settings.settings b/Samples/Stylet.Samples.OverridingViewManager/Properties/Settings.settings
new file mode 100644
index 0000000..033d7a5
--- /dev/null
+++ b/Samples/Stylet.Samples.OverridingViewManager/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Samples/Stylet.Samples.OverridingViewManager/ShellView.xaml b/Samples/Stylet.Samples.OverridingViewManager/ShellView.xaml
new file mode 100644
index 0000000..6aff50f
--- /dev/null
+++ b/Samples/Stylet.Samples.OverridingViewManager/ShellView.xaml
@@ -0,0 +1,8 @@
+
+
+ Hello, World
+
+
diff --git a/Samples/Stylet.Samples.OverridingViewManager/ShellView.xaml.cs b/Samples/Stylet.Samples.OverridingViewManager/ShellView.xaml.cs
new file mode 100644
index 0000000..5e5e80d
--- /dev/null
+++ b/Samples/Stylet.Samples.OverridingViewManager/ShellView.xaml.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace Stylet.Samples.OverridingViewManager
+{
+ ///
+ /// Interaction logic for ShellView.xaml
+ ///
+ [ViewModel(typeof(ShellViewModel))]
+ public partial class ShellView : Window
+ {
+ public ShellView()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/Samples/Stylet.Samples.OverridingViewManager/ShellViewModel.cs b/Samples/Stylet.Samples.OverridingViewManager/ShellViewModel.cs
new file mode 100644
index 0000000..1b22c0b
--- /dev/null
+++ b/Samples/Stylet.Samples.OverridingViewManager/ShellViewModel.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Stylet.Samples.OverridingViewManager
+{
+ public class ShellViewModel
+ {
+ }
+}
diff --git a/Samples/Stylet.Samples.OverridingViewManager/Stylet.Samples.OverridingViewManager.csproj b/Samples/Stylet.Samples.OverridingViewManager/Stylet.Samples.OverridingViewManager.csproj
new file mode 100644
index 0000000..5a51730
--- /dev/null
+++ b/Samples/Stylet.Samples.OverridingViewManager/Stylet.Samples.OverridingViewManager.csproj
@@ -0,0 +1,110 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {2F7D7EF3-730A-45E3-93CA-7C5031250246}
+ WinExe
+ Properties
+ Stylet.Samples.OverridingViewManager
+ Stylet.Samples.OverridingViewManager
+ v4.5
+ 512
+ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 4
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+ 4.0
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+
+
+
+
+ Code
+
+
+ True
+ True
+ Resources.resx
+
+
+ True
+ Settings.settings
+ True
+
+
+ ShellView.xaml
+
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+
+
+
+
+
+
+ {2435bd00-ac12-48b0-ad36-9bab2fdec3f5}
+ Stylet
+
+
+
+
+ Designer
+ MSBuild:Compile
+
+
+
+
+
\ No newline at end of file
diff --git a/Samples/Stylet.Samples.sln b/Samples/Stylet.Samples.sln
index 5650adf..3179e6c 100644
--- a/Samples/Stylet.Samples.sln
+++ b/Samples/Stylet.Samples.sln
@@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Stylet.Samples.MasterDetail
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Stylet.Samples.HelloDialog", "Stylet.Samples.HelloDialog\Stylet.Samples.HelloDialog.csproj", "{F6DD6F38-40A3-4EC1-B342-0C2BCCF0DD44}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Stylet.Samples.OverridingViewManager", "Stylet.Samples.OverridingViewManager\Stylet.Samples.OverridingViewManager.csproj", "{2F7D7EF3-730A-45E3-93CA-7C5031250246}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -39,6 +41,10 @@ Global
{F6DD6F38-40A3-4EC1-B342-0C2BCCF0DD44}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F6DD6F38-40A3-4EC1-B342-0C2BCCF0DD44}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F6DD6F38-40A3-4EC1-B342-0C2BCCF0DD44}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2F7D7EF3-730A-45E3-93CA-7C5031250246}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2F7D7EF3-730A-45E3-93CA-7C5031250246}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2F7D7EF3-730A-45E3-93CA-7C5031250246}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2F7D7EF3-730A-45E3-93CA-7C5031250246}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE