开发者

Marking a custom control as internal throws exception

There is a custom control called开发者_运维百科 TestCustomControl, it inherits from Control and it has a control template that is defined in generic.xaml.

It's the content of the Main Page.

If I mark it as public, it all works fine. But if I mark it as internal, it throws an exception: Invalid attribute value local:TestCustomControl for property TargetType. [Line: 74 Position: 12].

And this only happens in Windows Phone dev environment, I tried the similar thing in WPF and it works.

How can I mark a custom control as internal and use it in the main page in WP7?

Thanks

note: when I was using it in xaml, it throws exception. then I tested it by creating the control in code-behind and then add it to the logic tree, it throws exception too.


You can not mark it as internal since XAML will process most of things based only on reflection and in most cases reflection is only allowed for public types and public members.

If you make it internal then you can use it only in code not in xaml.


Is your control hosted in the main application or in a satelite dll?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜