XAML Page constructor
I have a Silverlight 4 application.
What would cause the Constructor in my codebehind file to be called more than once?
Currently I suspect it gets called when I set the datacontext or do applytemplate.
I can 开发者_如何学Pythonsee it when I debug the application and I put a breakpoint on the first line in my constructor, BUT it does not give me a stacktrace.
Thanks
I discovered that the MainPage.xaml.cs file can have a {usercontroname}_Loaded event.
I moved my method call that started the database query to that event instead of the constructor.
Works like a charm now.
the constructor should only be called once per control instance. Is your control maybe used more than once in your app? Or maybe a page that includes the control is instantiated more than once?
Cheers, Alex
精彩评论