I'm trying to access a control's text property from program.cs and it says that it is inaccessible due to protected level. How can I fix this please?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
The concept behind is the protection level. As we have studied in Object Oriented Paradigm keep your class members variables private and set or get it from Property.Thats why it is not a good approach
Use
x:FieldModifier="public"
e.g.as explained here: Modifying XAML named field visibility
In my case, I put UserControl in another DLL. WPF’s convention is to set all named fields as
internal
by default. Using thex:FieldModifier="public"
has solved the issue.This is the default property for controls, and can be solved by going into Design-View for the Form that contains the specified Control, then changing the Control's Modifiers property to Public or Internal. That oughta do it! :)
Control Protection level Resolved
Go to designer file search control By ID e.g txtModel change protected modifier to public modifier