WPF TextBlock Text binding
Hello i am working with wpf for very first time. I am trying to make a textbox with placeholder but when i try to use this resource it says
The member "Placeholder" is not recognized or is not accessible.
Here is my code
13 Replies
Try to make your view model class public
Yeah i have tried that but still same
When are you getting the mentioned error message? Upon the compilation? Because usually even if there are binding issues, it still compiles and runs.
Yeah i got that error on compilation
Did you try to run “clean solution”?
No i didnt let me try
now it is same and more
I have removed bin and obj folder and now my errors are these only
You see now? It looks for the Placeholder property in the TextboxPlaceholder class, not in the view model. This means that data context is not set properly. Try to put a breakpoint at the constructor of the TextboxPlaceholder. Does it been called? Also it could be helpful if you share your solution on GitHub or somewhere, the devil may hide in other details.
Actually i have changed the viewmodel class name while i am trying solutions at the end i couldnt find any solutions and i have completely removed the viewmodel class i am doing things in directly on PlaceholderTextbox.xaml.cs
now it works for sure and i have lost more than one day on here for looking solutions
so i stopped looking for solution
PlaceholderTextboxVM.cs
you can check these if you want but it still same i cannot build while i am using this properties