简体   繁体   English

Silverlight控件未加载

[英]Silverlight controls not loading

I'm working on a Silverlight 3.0 app, and about 1 out of every 10 or 20 times, a UserControl I've created won't load with the rest of the application. 我正在使用Silverlight 3.0应用程序,每10或20次中大约有1次,我创建的UserControl不会与应用程序的其余部分一起加载。 The rest of the application loads and functions correctly. 其余的应用程序可以正确加载和运行。 So far, I've been exclusively launching this from visual studio, but I'd like to be sure that this isn't something that will happen when it's actually deployed. 到目前为止,我一直是从Visual Studio专门启动此功能的,但我想确保在实际部署时不会发生这种情况。

Does anyone know what might be causing this? 有谁知道这可能是什么原因? Has anyone else experienced this? 其他人有没有经历过?

EDIT: the control's constructor (all animations are initialized) 编辑:控件的构造函数(所有动画都已初始化)

        InitializeComponent();

        m_CenterXAnimation.Duration = new TimeSpan(0, 0, 0, 0, 800);
        m_CenterYAnimation.Duration = new TimeSpan(0, 0, 0, 0, 800);

        m_FadeOutAnimation.Duration = new TimeSpan(0, 0, 5);
        m_FadeInAnimation.Duration = new TimeSpan(0, 0, 5);
        m_FadeOutAnimation.To = 0;
        m_FadeInAnimation.To = 1;

        m_ScaleDownAnimation.Duration = new TimeSpan(0, 0, 0, 0, 800);
        m_ScaleUpAnimation.Duration = new TimeSpan(0, 0, 0, 0, 800);
        m_ScaleDownAnimation.To = 1;
        m_ScaleUpAnimation.To = 1.1;   

        App.Current.Host.Content.Resized += new EventHandler(Content_Resized);

It sounds to me like you getting an exception within your UserControl that is not causing a full crash but is preventing your control from completing initialization. 在我看来,您好像在UserControl中遇到了一个异常,该异常不会导致完全崩溃,但会阻止您的控件完成初始化。 You could try debugging the initialization of the UserControl and it's bindings - start by placing a breakpoint in the unhandled exception handler of your App class. 您可以尝试调试UserControl及其绑定的初始化-首先在您的App类的未处理异常处理程序中放置一个断点。

I doubt the problem is with the UserControl. 我怀疑问题出在UserControl。 Sounds a like a timing issue. 听起来像是时间问题。 I've had similar problems but it was caused by other parts of the application - usually in the order events fire. 我也遇到过类似的问题,但这是由应用程序的其他部分引起的-通常是在订单事件触发时。 Nothing wrong with your example code - the issue lies elsewhere. 您的示例代码没有错-问题出在其他地方。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM