I have a user control with a ComboBox and a TextBox. Everything is working great except I noticed that from my user control's instance object, I can access those two controls. They shouldn't be accessible except via my own exposed properties.
R – How to make the controls inside a UserControl private
access-modifiersuser-controlswpf
Related Topic
- C# – Binding a WPF ComboBox to a custom list
- C# – Programmatically added User Control does not create its child controls
- C# – In C#, what is the difference between public, private, protected, and having no access modifier
- C# – expose and raise event of a child control in a usercontrol in c#
- R – ASP.NET: Viewstate and programmatically adding user controls
- C# – User Control – Custom Properties
Best Answer
You can use the x:FieldModifier attribute on your controls, thusly:
Interestingly the MSDN page for x:FieldModifier doesn't give "private" as a valid value for the attribute, but I've tested it and it works.