0

I am using Visual studio 2012 and I am trying to bind the textbox.isenable to static property static bool enable_disable

I am using the new feature of wpf4.5 and define static event StaticPropertyChanged and write in the XMAL

TextBox IsEnable="{Binding Path=(local:my_class.enable_disable)}" />

The problem is the application runs fine and the binding with notify of property changing run in correct way but the XMAL process complains from error that enable_disable is not dependency property and show markup invalid and I can't edit anything in UI.

I don't understand how the application and binding runs but the XMAL process has an error?

i know that
IsEnable="{Binding source ={x:static local:my_class.enable_disable)}" will work but the StaticPropertyChanged event = null but with my first solution work well with notify about changed property but why XMAL process has an error? how as it's new WPF feature provided by WPF 4.5?

  • Hi and welcome to SO, I formatted your question to make it easier to understand, please check it to make sure it describes your problem correctly. Also can you add the error you are getting? – Deepend Nov 24 '15 at 11:39
  • agree with the answer below this is a duplicate http://stackoverflow.com/a/938634/3225 – kenny Nov 24 '15 at 12:00
  • Possible duplicate of [Binding to static property](http://stackoverflow.com/questions/936304/binding-to-static-property) – kenny Nov 24 '15 at 12:01
  • @kenny Note that new syntax was added in WPF 4.5 (or 4.0?) for binding to static propertes. What OP does is valid, and as he says, "runs fine". Apparently it's just the XAML Designer complaining. – Clemens Nov 24 '15 at 12:33
  • @Mohamed Did you try to restart Visual Studio? – Clemens Nov 24 '15 at 12:35
  • thanks for your comments yes this solution : IsEnable="{Binding source ={x:static local:my_class.enable_disable)}" work well but i want to know why my first solution doesn't work – Mohamed Safwat Nov 24 '15 at 18:08

0 Answers0