命名空间中的可见性c#wpf

时间:2018-04-15 14:48:12

标签: c# mvvm namespaces visibility

我应该如何向项目添加文件以使其在指定的命名空间中可见?

例如:

我在项目中有文件夹ViewModels。当我试图将一些.cs文件添加到该命名空间时,我在该项目的代码的不同部分出现错误The name "MenuItem" does not exist in the namespace "clr-namespace:P1.ViewModels".

我是否应该添加一些对该文件的引用来告诉程序" MainWindow内容取决于该MenuItem文件"或者使MenuItem文件特别属于该命名空间??

提前谢谢

using System;
using System.Windows.Input;
using P1.Mvvm;

namespace P1.ViewModels
{
    public class MenuItem : BindableBase
    {
        private object _icon;
        private string _text;
        private bool _isEnabled = true;
        private DelegateCommand _command;
        private Uri _navigationDestination;

    public object Icon
    {
        get { return this._icon; }
        set { this.SetProperty(ref this._icon, value); }
    }

    public string Text
    {
        get { return this._text; }
        set { this.SetProperty(ref this._text, value); }
    }

    public bool IsEnabled
    {
        get { return this._isEnabled; }
        set { this.SetProperty(ref this._isEnabled, value); }
    }

    public ICommand Command
    {
        get { return this._command; }
        set { this.SetProperty(ref this._command, (DelegateCommand)value); }
    }

    public Uri NavigationDestination
    {
        get { return this._navigationDestination; }
        set { this.SetProperty(ref this._navigationDestination, value); }
    }

    public bool IsNavigation => this._navigationDestination != null;
}

}

0 个答案:

没有答案