WPF, Bad practice to put code directly after InitializeComponent?

后端 未结 2 1512
梦谈多话
梦谈多话 2021-01-21 11:47

I was just wondering about something. I have a frame that loads pages and currently each page has a Page_Loaded method that will run each time the page is accessed

2条回答
  •  -上瘾入骨i
    2021-01-21 12:18

    It's legitimate to do something in the constructor. I think this is fine.

    WPF isn't quite like ASP.NET in terms of accessibility of objects / etc. It's a bit looser and so doing something in a constructor isn't quote the no-no it is in ASP.NET.

提交回复
热议问题