### Generated View Mappings Source: https://github.com/wieslawsoltes/staticviewlocator/blob/main/README.md Example of the generated lookup dictionaries for views and missing views. ```csharp public partial class ViewLocator { private static Dictionary> s_views = new() { [typeof(StaticViewLocatorDemo.ViewModels.TestViewModel)] = () => new StaticViewLocatorDemo.Views.TestView(), }; private static Dictionary s_missingViews = new() { [typeof(StaticViewLocatorDemo.ViewModels.MainWindowViewModel)] = "Not Found: StaticViewLocatorDemo.Views.MainWindowView", }; } ``` -------------------------------- ### Add NuGet Package Reference Source: https://github.com/wieslawsoltes/staticviewlocator/blob/main/README.md Include the StaticViewLocator package in your project file. ```xml all runtime; build; native; contentfiles; analyzers ``` -------------------------------- ### Implement ViewLocator with StaticViewLocator Attribute Source: https://github.com/wieslawsoltes/staticviewlocator/blob/main/README.md Annotate a partial class with [StaticViewLocator] and implement the IDataTemplate interface to handle view resolution. ```csharp [StaticViewLocator] public partial class ViewLocator : IDataTemplate { public Control? Build(object? data) { if (data is null) { return null; } var type = data.GetType(); var func = TryGetFactory(type) ?? TryGetFactoryFromInterfaces(type); if (func is not null) { return func.Invoke(); } var missingView = TryGetMissingView(type) ?? TryGetMissingViewFromInterfaces(type); if (missingView is not null) { return new TextBlock { Text = missingView }; } throw new Exception($"Unable to create view for type: {type}"); } public bool Match(object? data) { return data is ViewModelBase; } } ``` -------------------------------- ### Configure StaticViewLocator via MSBuild Source: https://github.com/wieslawsoltes/staticviewlocator/blob/main/README.md Define project-level properties within a PropertyGroup to control how view models are mapped to views. ```xml MyApp.ViewModels;MyApp.Modules false false MyApp.Controls.ToolWindowBase ViewModels=Views ViewModel=View;Vm=Page true I ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.