2

i have below error in my C# wpf user control library :

Severity Code Description Project File Line Error CS0234 The type or namespace name 'StylesTemplates' does not exist in the namespace 'MHToolkit'(are you missing an assembly reference?)'`

i have resource dictionary in the folder, the error will be disappear when i Exclude StylesTemplate Folder from the project

and i am using it in usercontrol this my user control code :

<UserControl x:Class="MHToolkit.UserControl1"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:MHToolkit"
             xmlns:ST="clr-namespace:MHToolkit.StylesTemplates"
             xmlns:VM="clr-namespace:MHToolkit.ViewModels"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <VM:MainViewModel x:Key="MainVM" />
    </UserControl.Resources>
    <UserControl.DataContext>
        <Binding Source="{StaticResource MainVM}" />
    </UserControl.DataContext>


    <Grid>

    </Grid> </UserControl>

i am using vs2014 and .net 4.5 .

i have no idea how to fix this error ?

any help will be appreciated

tanx in advance

image of solution explorer window below

enter image description here

MH480
  • 51
  • 1
  • 8

1 Answers1

1

Add CardViewStyle.xaml as the Resource Dictionary Check the below code

Add this to the current Usercontrol

 <UserControl.Resources>
   <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/MHToolkit;component/StylesTemplates/CardviewStyle.xaml" />
        </ResourceDictionary.MergedDictionaries>
 </ResourceDictionary>

Otherwise you can add App.xaml file and used all apllication

<Application.Resources>
   <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/MHToolkit;component/StylesTemplates/CardviewStyle.xaml" />
        </ResourceDictionary.MergedDictionaries>
 </ResourceDictionary>

A. S. Mahadik
  • 585
  • 1
  • 5
  • 17