使用用户控件时出现 XamlParseException
我面临以下问题:
我在 XAML 中创建了一个关联了 x:Name 的用户控件,因为我内部有一些需要此名称的绑定。在主页上,我使用此用户控件的多个实例,突然抛出 XamlParseException,告诉我该名称已在使用中;但这并不总是发生。
有人有同样的问题吗?有人知道如何解决这个问题吗?
Op 的更新来自下面的评论(可能会被删除):
据我所知,这是 Silverlight 的一个已知错误。
我的解决方法是通过将控件本身设置为 DataContext 来避免多次使用的用户控件上的名称属性,然后使用绑定来使事情正常工作。
I'm facing the following problem:
I have created a user control in XAML that has an x:Name associated because I have some bindings internally that need this name. On the main page I use multiple instances of this user control and all of the sudden a XamlParseException is thrown which tells me that the name is already in use; but this does not happen always.
Does anybody have the same issue? Has anybody an idea on how to resolve this?
Op's update from a comment, below (which may be deleted):
As I found out, this is a known bug of Silverlight.
My workaround was to avoid the name attribute on user controls that I use multiple times by setting the control itself as DataContext and then I used bindings to get things working.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论