다음을 통해 공유


방법: 애플리케이션의 모든 창 가져오기

이 예제에서는 애플리케이션의 모든 Window 개체를 가져오는 방법을 보여 줍니다.

예제

모든 인스턴스화된 Window 개체는 표시 여부에 관계없이 Application으로 관리되고 Windows에서 노출되는 창 참조 컬렉션에 자동으로 추가됩니다.

다음 코드를 사용하여 모든 인스턴스화된 창을 가져오기 위해 Windows를 열거할 수 있습니다.

foreach( Window window in Application.Current.Windows ) {
  Console.WriteLine(window.Title);
}
For Each window As Window In Application.Current.Windows
  Console.WriteLine(window.Title)
Next window