Cannot find resource named 'ViewModelLocator' exception

cannot find resource named 'locator resource names are case sensitive
cannot find resource named viewmodellocator
cannot find resource named viewmodellocator resource names are case sensitive
wpf can t find static resource
xamlparseexception cannot find resource
vsxaml_disable_on_demand_resource_values
wpf dynamicresource
the resource materialdesignfloatinghinttextbox could not be resolved

I am trying to use ViewModelLocator by declaring it as a resource in App.xaml. Its a very simple class as follows:

public class ViewModelLocator
    {
        public ShellViewModel ShellPage
        {
            get
            {
                return new ShellViewModel();
            }
        }
}

App.xaml file is as below:

<Application x:Class="SomeNamespace.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:vm="clr-namespace:SomeNamespace.ViewModels">
    <Application.Resources>
         <vm:ViewModelLocator x:Key="ViewModelLocator" />
    </Application.Resources>
</Application>

App.xaml.cs is as below:

public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            var view = new ShellView();
            Current.MainWindow = view;
            Current.MainWindow.Show();            
        }
    }

ShellView.xaml is a below:

<Window 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        x:Class="SomeNamespace.ShellView"
        Title="MainWindow" 
        Height="350" 
        Width="525" 
        ResizeMode="NoResize" 
        MinWidth="700" 
        MinHeight="700"
        DataContext="{Binding ShellPage, Source={StaticResource ViewModelLocator}}"
        >
    <Grid>
        <TextBlock Text="{Binding Title}"></TextBlock>
    </Grid>
</Window>

I can see the correct title in Visual Studio designer but when i run the app, get XamlParseException: 'Provide value on 'System.Windows.StaticResourceExtension' threw an exception.' Line number '11' and line position '9'.

The innerexception has {"Cannot find resource named 'ViewModelLocator'. Resource names are case sensitive."}

Am i missing something ?

Try putting it inside a ResourceDictionary

<Application.Resources>
    <ResourceDictionary>
        <vm:ViewModelLocator x:Key="ViewModelLocator" />
    </ResourceDictionary>
</Application.Resources>

Edit:

I solved the problem by using the Startup event in the App, instead of overriding OnStartup.

<Application x:Class="TestWPF.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:vm="clr-namespace:TestWPF.ViewModels"
             Startup="App_Startup">
    <Application.Resources>
          <vm:ViewModelLocator x:Key="ViewModelLocator" />
    </Application.Resources>
</Application>

Code

public partial class App : Application
{
    void App_Startup(object sender, StartupEventArgs e)
    {
        var view = new ShellView();
        Current.MainWindow = view;
        Current.MainWindow.Show();
    }
}

Cannot find resource named 'CloseButton'. Resource names are , In order to use StaticResource , the style has to be defined before the element you are trying to apply it to within the same visual tree. You could� Example 1: Search for resources by type and resource group name PS C:\>Find-AzureRmResource -ResourceType "microsoft.web/sites" -ResourceGroupNameContains "ResourceGroup" This command searches for resources of the type microsoft.web/sites under resource groups that have names that match the string ResourceGroup.

At startup time you're loading the window, this is not a good practice in my opinion because the resources are not yet entirely resolved in both App in witch your Window depends. Even if you're seeing properties loading at design time this is not always a good argument, though design is following another logic to execute the code. You have to let App and Windows load and then fill the context property in the Window's grid

Remove the resource XAML from App.xaml (it looks really out of the scope there) and do this instead :

 <Window.Resources>
        <wpfApplication1:ViewModelLocator x:Key="ViewModelLocator" />
    </Window.Resources>

    <Grid   DataContext="{Binding ShellPage, Source={StaticResource ViewModelLocator}}">
        <TextBlock Text="{Binding Title}"></TextBlock>
    </Grid>

Cannot find resource named 'MaterialDesignComboBox'. Resource , Cannot find resource named 'MaterialDesignComboBox'. Resource names are case sensitive #28. Closed. UnRunDeaD opened this issue on Jan 24, 2019 � 14 � Hello, I'm trying to include a multiple option floating action button. In the sample app, an example can be seen here. In an attempt to add a multiple option floating action button into my app, I copied the code highlighted here.

It seems i found a solution.The reason maybe the StartUrl in the App.xaml.

1.Remove the default StartUrl in the App.xaml.Such like this:

        <Application x:Class="BidingAccessories.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" d1p1:Ignorable="d"
                     xmlns:d1p1="http://schemas.openxmlformats.org/markup-compatibility/2006">
            <Application.Resources>
                <ResourceDictionary>
                    <vm:ViewModelLocator x:Key="Locator" xmlns:vm="clr-namespace:BidingAccessories.ViewModel" />
                    <ResourceDictionary.MergedDictionaries>
                        <ResourceDictionary Source="pack://application:,,,/BidingCommon;component/CommonStyleDictionary.xaml" />
                    </ResourceDictionary.MergedDictionaries>
                </ResourceDictionary>
            </Application.Resources>
        </Application>
        </Application.Resources>
        </Application>

2. override the OnstartUp event in App.xaml.cs

    protected override void OnStartup(StartupEventArgs e)
        {
            StartupUri = new Uri("MainWindow.xaml", UriKind.Relative);
    }

Exception: Cannot find resource named 'nameItemTemplate'., Exception: Cannot find resource named 'nameItemTemplate'. Resource names are case sensitive. #7439. Closed. tapiov opened this issue on� Add MUXC to application resource; Have UITestMethod navigate to page containing a MUXC NavigationView control; Expected behavior Test will not throw: Windows.UI.Xaml.Markup.XamlParseException:.. Cannot find a Resource with the Name/Key TabViewItemHeaderBackground [Line: 18 Position: 69]' Version Info Project Target Version: Win 10.0 18362

Remove this part of code and run again. I am not sure about what's happening internally but that is what throwing the exception.

Error (Cannot find resource) in Visual Studio 2017 , Cannot find resource named <Resource name>. Resource names are case sensitive. Note. The static resource keys of the UI components that� Cannot find resource named 'ViewModelLocator' exception. Ask Question Asked 6 years, 9 months ago. Active 5 months ago. Viewed 5k times 1. I am trying to use

"XamlParseException: Cannot find resource named" problem, XamlParseException: Cannot find resource named '{OrangeButton}'. Resource names are case sensitive. Error at object 'System.Windows. Exception: Cannot find resource named '*'. Resource names are case sensitive. Ask Question Asked 1 year, 1 month ago. Active 1 year, 1 month ago.

Cannot find resource named 'RepeatButtonStyle' design time , Cannot find resource named 'RepeatButtonStyle' design time exception in Green theme (NoXaml). I put a ReportViewer in an application and� The Get-AzResourceGroup cmdlet gets Azure resource groups in the current subscription. You can get all resource groups, or specify a resource group by name or by other properties. By default, this cmdlet gets all resource groups in the current subscription. For more information about Azure resources and Azure resource groups, see the New-AzResourceGroup cmdlet.

“Cannot find resource named” error in XAML Workflow in Visual , I am receiving the “Cannot find resource named” error when trying to load an XAML workflow in Visual Studio 2017 (ver. 15.9.14). This was� I copied and pasted the the code into my App.xmal and noticed all the brushes had intellisense issues with errors like "Resource 'Primary200' is not found. Thought maybe it was resharper so tried running my app anyway and got this exception. Exception: Cannot find resource named 'Primary200'. Resource names are case sensitive.

Comments
  • +1 because the documentation is horrible for adding a View/ViewModel in MVVM-Light.
  • @ZachSmith Here I am just using my own simple ViewModelLocator class and nothing from MVVM light.
  • I realized. Sorry about that.
  • @mdm20 now i dont get the error but the window does not show up
  • Try deleting and re-creating app.xaml. Remember to set build action to ApplicationDefinition
  • click the above link to see the image.