开发者

Children Controls Are Inaccessible Due to Access Modifier

开发者 https://www.devze.com 2022-12-14 03:33 出处:网络
When I create a user control in WPF it would appear that all the children of this control are declared as internal? I\'ve not been able to verify this, nor finding any resources discussing this matter

When I create a user control in WPF it would appear that all the children of this control are declared as internal? I've not been able to verify this, nor finding any resources discussing this matter at all.

I can access the controls in the same assembly, but not in a project referencing the assembly where the user control is located. Is there a way to override the default access modifier of child controls in XAML so I don't manually have t开发者_StackOverflowo expose the controls via properties in the user control?


Have you tried to set the x:FieldModifier attribute of your children controls to "public"?


However, just making them public, is no good idea - its really bad design.

You should expose their real data through properties of your UserControl. The best thing would be introducing an interface.

Another solution (more the "WPF-way") would be using the data-context as the only property which is accessed from outside: The controls could bind to the properties they need.

0

精彩评论

暂无评论...
验证码 换一张
取 消