使用用户控件时出现 XamlParseException

发布于 2024-09-30 20:42:43 字数 372 浏览 1 评论 0原文

我面临以下问题:

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文