Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a class which used as DataSource

namespace DictMainUI.Model
{
    class SearchListItem:INotifyPropertyChanged
    {
        private string word;
        private int checkamount;
        ............
        public string Word
        {
            get { return this.word; }
            set
            {
                this.word = value;
                OnPropertyChanged(Word);
            }
        }
        public int CheckAmount
        {
            get { return this.checkamount; }
            set
            {
                if (value < 0)
                {
                    throw new ArgumentException("Price must be positive");
                }
                this.checkamount = value;
                OnPropertyChanged("CheckAmount");
            }
        }
.............


I want to define a datetemplate for ListboxItem that I want to bind to SearchListItem.

I have a ResourceDictionary, I want to define DataTemplate in this resource.
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                   
                    >


so I think I should add namespace to in order to expose SearchListItem attributes to this ResourceDictionary. but once I add it to the resourcedictionary , building project is failed without any message, and when run it, it shows error it says:set output and assembly name correct or something like that .code shown below (which show error as I said)

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                   xmlns:src="clr-namespace:DictMainUI.Model"
                    >


it got wrong when I add DictMainUI.Model namespace to the ResourceDictionary.

I did not know why it dose not work,is there anyone give me a advice on that problem?

thanks in advance!
Posted
Updated 21-Mar-12 21:32pm
v3

If the namespace is in another assembly, you have to provide the assembly's name too, like the following:


HTML
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:src="clr-namespace:DictMainUI.Model;assembly=DictMainUI.Model"
                    >
 
Share this answer
 
Comments
Alimjan Yasin 22-Mar-12 4:24am    
it is not in another assembly, even it is I tried, but did not work. what should I do now?
Shmuel Zang 22-Mar-12 5:19am    
Do you get the error also when you omit the xmlns:src="clr-namespace:DictMainUI.Model" line?
Alimjan Yasin 22-Mar-12 5:26am    
there is no error when code is like this:
<resourcedictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

I got error when I add the line of code :
xmlns:src="clr-namespace:DictMainUI.Model"
I don't know what happened to the project, after tried to fix it many times I give up on that project , and build whole new project and mapping custome class to resourcedictionary is worked on this one.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900