![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | Window.Loaded Hi! I noticed that my Window.Loaded eventhandler is triggered twice. When I remove the event wiring from the Xaml the handler is not being called so I know I didn't trigger the Loaded method by hand. Anybody any clue or suggestion what is going on? Thanks! Erno ---- WPF tutorials: http://blogs.infosupport.com/ernow/articles/1878.aspx |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Window.Loaded I'm seeing something similar to this, too, for example, in MyApp.xaml with the following code: <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Styles.xaml"/> .. .. .. Error at element 'ResourceDictionary' in markup file 'Window1.xaml' : Item has already been added. Key in dictionary: 'lbiDataTemplate1' Key being added: 'lbiDataTemplate1'. I've found that if I rebuild the project, everything works and I don't get the error. It can happen after a minor edit of an unrelated XAML file in the project. Greg Erno wrote: > Hi! > > I noticed that my Window.Loaded eventhandler is triggered twice. When I > remove the event wiring from the Xaml the handler is not being called so I > know I didn't trigger the Loaded method by hand. > > Anybody any clue or suggestion what is going on? > > Thanks! > > Erno > ---- > WPF tutorials: http://blogs.infosupport.com/ernow/articles/1878.aspx > > > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Window.Loaded Solved, I think. I forgot to REMOVE one of the old "<?Mapping" PIs from a XAML file after making the described changes for Feb CTP. Greg Greg K wrote: > I'm seeing something similar to this, too, for example, in MyApp.xaml > with the following code: > > <Application.Resources> > <ResourceDictionary> > <ResourceDictionary.MergedDictionaries> > <ResourceDictionary Source="Styles.xaml"/> > .. > .. > .. > > Error at element 'ResourceDictionary' in markup file 'Window1.xaml' : > Item has already been added. Key in dictionary: 'lbiDataTemplate1' Key > being added: 'lbiDataTemplate1'. > > I've found that if I rebuild the project, everything works and I don't > get the error. It can happen after a minor edit of an unrelated XAML > file in the project. > > Greg > > > Erno wrote: >> Hi! >> >> I noticed that my Window.Loaded eventhandler is triggered twice. When >> I remove the event wiring from the Xaml the handler is not being >> called so I know I didn't trigger the Loaded method by hand. >> >> Anybody any clue or suggestion what is going on? >> >> Thanks! >> >> Erno >> ---- >> WPF tutorials: http://blogs.infosupport.com/ernow/articles/1878.aspx >> >> >> |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Window.Loaded Greg, I don't see how this relates to 'my' problem... Cheers Erno "Greg K" <gregk@smudgeybear.com> wrote in message news:%23muyfKIOGHA.1288@TK2MSFTNGP09.phx.gbl... > I'm seeing something similar to this, too, for example, in MyApp.xaml with > the following code: > > <Application.Resources> > <ResourceDictionary> > <ResourceDictionary.MergedDictionaries> > <ResourceDictionary Source="Styles.xaml"/> > . > . > . > > Error at element 'ResourceDictionary' in markup file 'Window1.xaml' : Item > has already been added. Key in dictionary: 'lbiDataTemplate1' Key being > added: 'lbiDataTemplate1'. > > I've found that if I rebuild the project, everything works and I don't get > the error. It can happen after a minor edit of an unrelated XAML file in > the project. > > Greg > > > Erno wrote: >> Hi! >> >> I noticed that my Window.Loaded eventhandler is triggered twice. When I >> remove the event wiring from the Xaml the handler is not being called so >> I know I didn't trigger the Loaded method by hand. >> >> Anybody any clue or suggestion what is going on? >> >> Thanks! >> >> Erno >> ---- >> WPF tutorials: http://blogs.infosupport.com/ernow/articles/1878.aspx >> >> |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Window.Loaded Erno, Granted it may not be related, but you mentioned that your Window.Loaded event handler was being called twice, and from the error message I posted, my DataTemplate is being merged twice into the ResourceDictionary in Application.Resources. Both your problem and mine appear to happen on startup as well, and I assume your app was working as well unchanged with Jan/Dec CTP. If you leave the Loaded event wired, does the problem still occur if you do a complete project rebuild, then run it ? Greg Erno wrote: > Greg, > > I don't see how this relates to 'my' problem... > > Cheers > > Erno > > "Greg K" <gregk@smudgeybear.com> wrote in message > news:%23muyfKIOGHA.1288@TK2MSFTNGP09.phx.gbl... >> I'm seeing something similar to this, too, for example, in MyApp.xaml with >> the following code: >> >> <Application.Resources> >> <ResourceDictionary> >> <ResourceDictionary.MergedDictionaries> >> <ResourceDictionary Source="Styles.xaml"/> >> . >> . >> . >> >> Error at element 'ResourceDictionary' in markup file 'Window1.xaml' : Item >> has already been added. Key in dictionary: 'lbiDataTemplate1' Key being >> added: 'lbiDataTemplate1'. >> >> I've found that if I rebuild the project, everything works and I don't get >> the error. It can happen after a minor edit of an unrelated XAML file in >> the project. >> >> Greg >> >> >> Erno wrote: >>> Hi! >>> >>> I noticed that my Window.Loaded eventhandler is triggered twice. When I >>> remove the event wiring from the Xaml the handler is not being called so >>> I know I didn't trigger the Loaded method by hand. >>> >>> Anybody any clue or suggestion what is going on? >>> >>> Thanks! >>> >>> Erno >>> ---- >>> WPF tutorials: http://blogs.infosupport.com/ernow/articles/1878.aspx >>> >>> > |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Window.Loaded Wow! A full rebuild cleared that up! Ok, I'm switching to Always full rebuild... Thanks Greg! Erno ---- WPF tutorials: http://blogs.infosupport.com/ernow/articles/1878.aspx "Greg K" <gregk@smudgeybear.com> wrote in message news:%23oSgCNMOGHA.1460@TK2MSFTNGP10.phx.gbl... > Erno, > > Granted it may not be related, but you mentioned that your Window.Loaded > event handler was being called twice, and from the error message I posted, > my DataTemplate is being merged twice into the ResourceDictionary in > Application.Resources. Both your problem and mine appear to happen on > startup as well, and I assume your app was working as well unchanged with > Jan/Dec CTP. > > If you leave the Loaded event wired, does the problem still occur if you > do a complete project rebuild, then run it ? > > Greg > > Erno wrote: >> Greg, >> >> I don't see how this relates to 'my' problem... >> >> Cheers >> >> Erno >> >> "Greg K" <gregk@smudgeybear.com> wrote in message >> news:%23muyfKIOGHA.1288@TK2MSFTNGP09.phx.gbl... >>> I'm seeing something similar to this, too, for example, in MyApp.xaml >>> with the following code: >>> >>> <Application.Resources> >>> <ResourceDictionary> >>> <ResourceDictionary.MergedDictionaries> >>> <ResourceDictionary Source="Styles.xaml"/> >>> . >>> . >>> . >>> >>> Error at element 'ResourceDictionary' in markup file 'Window1.xaml' : >>> Item has already been added. Key in dictionary: 'lbiDataTemplate1' Key >>> being added: 'lbiDataTemplate1'. >>> >>> I've found that if I rebuild the project, everything works and I don't >>> get the error. It can happen after a minor edit of an unrelated XAML >>> file in the project. >>> >>> Greg >>> >>> >>> Erno wrote: >>>> Hi! >>>> >>>> I noticed that my Window.Loaded eventhandler is triggered twice. When I >>>> remove the event wiring from the Xaml the handler is not being called >>>> so I know I didn't trigger the Loaded method by hand. >>>> >>>> Anybody any clue or suggestion what is going on? >>>> >>>> Thanks! >>>> >>>> Erno >>>> ---- >>>> WPF tutorials: http://blogs.infosupport.com/ernow/articles/1878.aspx >>>> >>>> >> |
My System Specs![]() |
| | #7 (permalink) |
| | Re: Window.Loaded I was getting the same problem. you need to set e.Handled=true at the end of your OnLoaded handler. private void OnLoaded(object sender, RoutedEventArgs e) { ... e.Handled = true; } |
My System Specs![]() |
| | #8 (permalink) |
| | Re: Window.Loaded I think that this is a hack or work-around and definitly not the way to do this. Full rebuild fixed it for me. Erno ---- WPF tutorials: http://blogs.infosupport.com/ernow/articles/1878.aspx "damien morton" <damien.morton@gmail.com> wrote in message news:1140805758.876996.40500@e56g2000cwe.googlegroups.com... >I was getting the same problem. > > you need to set e.Handled=true at the end of your OnLoaded handler. > > private void OnLoaded(object sender, RoutedEventArgs e) > { > ... > e.Handled = true; > } > |
My System Specs![]() |
| | #9 (permalink) |
| | Re: Window.Loaded Full rebuild didnt seem to stop the two OnLoaded events for me. |
My System Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Can't get on net after update loaded | Vista General | |||
| No loaded with 64 bit? | Vista General | |||
| COM Add-in could not be loaded after UAC is disabled | Vista security | |||
| 100% CPU loaded | Vista performance & maintenance | |||
| 100% CPU loaded | Vista performance & maintenance | |||