Home > Net > There was a problem WPF access to all Windows
There was a problem WPF access to all Windows
Time:02-23
Public partial class Window for testing: the Window { Public void init () { WindowCollection WindowCollection=App. Current. Windows; Foreach (Window Window in windowCollection) { List2. Items. The Add (window. The Title); } } Public Window for testing () { InitializeComponent (); init(); } } This code is used to retrieve the current window, and insert it into the ListBox named list2, but in actual operation, I only opened the three Windows, more than five items, there are two show not to come out, want to please the great god what is this, Results: 1. The Window1 2. (no content) blank, 3. Window2 4. (no content) blank, 5. Window3 I am a high school student, the self-study of the holidays WPF some knowledge, knowledge is not strong in some places, hoping to make allowance for it
CodePudding user response:
WindowCollection WindowCollection=App. Current. Windows; Foreach (Window Window in windowCollection) { If (window is the window) ListBox1. Items. The Add (window. The Title); }