Binding to static property

后端 未结 12 2294
夕颜
夕颜 2020-11-22 05:14

I\'m having a hard time binding a simple static string property to a TextBox.

Here\'s the class with the static property:



        
12条回答
  •  温柔的废话
    2020-11-22 05:45

    Leanest answer (.net 4.5 and later):

        static public event EventHandler FilterStringChanged;
        static string _filterString;
        static public string FilterString
        {
            get { return _filterString; }
            set
            {
                _filterString= value;
                FilterStringChanged?.Invoke(null, EventArgs.Empty);
            }
        }
    

    and XAML:

        
    

    Don't neglect the brackets

提交回复
热议问题