0
我已經將公共屬性轉換爲公共變量,以使代碼更簡單,現在組合框的綁定機制將不起作用。我不能使用變量而不是屬性?WPF綁定:屬性與變量
工作代碼:作爲財產
internal class Utility
{
#region ReportOf
public enum ReportOf
{
Choose, All, Group, Person
}
private static Dictionary<ReportOf, string> _dictReportOf;
public static Dictionary<ReportOf, string> ReportOfCollection
{
get { return _dictReportOf; }
}
#endregion ReportOf
static Utility()
{
//initialize the collection with user friendly strings for each enum
_dictReportOf = new Dictionary<ReportOf, string>(){
{ReportOf.Choose, "Lütfen seçiniz..."},
{ReportOf.All, "Herkes"},
{ReportOf.Group, "Grup"},
{ReportOf.Person, "Şahıs"}};
}
}
非工作端口:可變
internal class Utility
{
#region ReportOf
public enum ReportOf
{
Choose,
All,
Group,
Person
}
public static Dictionary<ReportOf, string> ReportOfCollection = new Dictionary<ReportOf, string>()
{
{ReportOf.Choose, "Lütfen seçiniz..."},
{ReportOf.All, "Herkes"},
{ReportOf.Group, "Grup"},
{ReportOf.Person, "Şahıs"}
};
#endregion ReportOf
static Utility()
{
//Nothing to do
}
}
事實上,你通常不想這樣做,因爲你需要綁定到屬性,讓它們擁有觸發有用事物的setter,如INotifyPropertyChanged。 –