© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•8mo ago•
70 replies
Fuxsy foxシ

✅ How to use ResourceDictionary in the App.xaml?

I want to build an application with Dependency Injection and I've finished everything. All that's left is to make the
DataTemplate
DataTemplate
for all the windows.
Now I tried to do this using a new DataTemplate.xaml file but it doesn't work for me because the file doesn't see the other functions. for example

 xaml
    <DataTemplate DataType="{x:Type vm:TweaksVM}">
        <view:Tweaks />
    </DataTemplate>
 xaml
    <DataTemplate DataType="{x:Type vm:TweaksVM}">
        <view:Tweaks />
    </DataTemplate>

I added the correct namespaces at least I think so
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:view="clr-namespace:WinRep_Code.Views"
                    xmlns:vm="clr-namespace:WinRep_Code.ViewModels">
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:view="clr-namespace:WinRep_Code.Views"
                    xmlns:vm="clr-namespace:WinRep_Code.ViewModels">


and i got these errors
The name "Tweaks" does not exist in the namespace "clr-namespace:WinRep_Code.Views".
The name "TweaksVM" does not exist in the namespace "clr-namespace:WinRep_Code.ViewModels".

I guess I don't know how to use this in the App.xaml file but I don't know anymore
added the file tree
C:.
│   App.xaml
│   App.xaml.cs
│   AssemblyInfo.cs
│   WinRep-Code.csproj
│   WinRep-Code.csproj.user
│   WinRep-Code.sln
│
├───Utilities
│       BaseViewModel.cs
│       DataTemplate.xaml
│       NavigationService.cs
│       RelayCommand.cs
│
├───ViewModels
│       CustomTweaksVM.cs
│       InstallVM.cs
│       MainWindowVM.cs
│       ScanSettingsVM.cs
│       ScanVM.cs
│       TweaksVM.cs
│
└───Views
        CustomTweaks.xaml
        Install.xaml
        MainWindow.xaml
        Scan.xaml
        ScanSettings.xaml
        Tweaks.xaml
C:.
│   App.xaml
│   App.xaml.cs
│   AssemblyInfo.cs
│   WinRep-Code.csproj
│   WinRep-Code.csproj.user
│   WinRep-Code.sln
│
├───Utilities
│       BaseViewModel.cs
│       DataTemplate.xaml
│       NavigationService.cs
│       RelayCommand.cs
│
├───ViewModels
│       CustomTweaksVM.cs
│       InstallVM.cs
│       MainWindowVM.cs
│       ScanSettingsVM.cs
│       ScanVM.cs
│       TweaksVM.cs
│
└───Views
        CustomTweaks.xaml
        Install.xaml
        MainWindow.xaml
        Scan.xaml
        ScanSettings.xaml
        Tweaks.xaml

help 🙏🏻
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements
Next page

Similar Threads

App.xaml
C#CC# / help
17mo ago
✅ How to use SVGs in XAML file (WPF)
C#CC# / help
3y ago
✅ Can't use external font in resourcedictionary?
C#CC# / help
3y ago
How to Correctly Reference a Method in App.xaml.cs
C#CC# / help
13mo ago