Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have handled this sort of situation in the past by bringing in the concept of a <code>WindowManager</code>, which is a <em>horrible</em> name for it, so let's pair it with a <code>WindowViewModel</code>, which is only slightly less horrible - but the basic idea is:</p> <pre><code>public class WindowManager { public WindowManager() { VisibleWindows = new ObservableCollection&lt;WindowViewModel&gt;(); VisibleWindows.CollectionChanged += OnVisibleWindowsChanged; } public ObservableCollection&lt;WindowViewModel&gt; VisibleWindows {get; private set;} private void OnVisibleWindowsChanged(object sender, NotifyCollectionChangedEventArgs args) { // process changes, close any removed windows, open any added windows, etc. } } public class WindowViewModel : INotifyPropertyChanged { private bool _isOpen; private WindowManager _manager; public WindowViewModel(WindowManager manager) { _manager = manager; } public bool IsOpen { get { return _isOpen; } set { if(_isOpen &amp;&amp; !value) { _manager.VisibleWindows.Remove(this); } if(value &amp;&amp; !_isOpen) { _manager.VisibleWindows.Add(this); } _isOpen = value; OnPropertyChanged("IsOpen"); } } public event PropertyChangedEventHandler PropertyChanged = delegate {}; private void OnPropertyChanged(string name) { PropertyChanged(this, new PropertyChangedEventArgs(name)); } } </code></pre> <p>note: I'm just throwing this together very haphazardly; you'd of course want to tune this idea to your specific needs. </p> <p>But anywho, the basic premise is your commands can work on the <code>WindowViewModel</code> objects, toggle the <code>IsOpen</code> flag appropriately, and the manager class handles opening/closing any new windows. There are dozens of <em>possible</em> ways to do this, but it's worked in a pinch for me in the past (when actually implemented and not tossed together on my phone, that is)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload