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?
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?
Use x:FieldModifier="public"
e.g.
<TextBlock x:FieldModifier="public" x:Name="AccessibleTextBlock" />
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 the x:FieldModifier="public" has solved the issue.