Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As far as I understand your question, you can solve this by having <code>UC</code> expose a <code>SelectedSubView</code> (or whatever) property:</p> <pre><code>public object SelectedSubView { get; } </code></pre> <p>At the same time, you bind the radiobuttons to other properties of <code>UC</code> and update <code>SelectedSubView</code> accordingly (remember to implement INotifyPropertyChanged). Based on the selected radiobutton properties, the <code>SelectedSubView</code> must return the appropriate ViewModel.</p> <p>You then bind a <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.contentpresenter.aspx" rel="nofollow noreferrer">ContentPresenter</a> to the <code>SelectedSubView</code> property and use <strong>DataTemplates</strong> to select the correct user controls (uc1, uc2 or uc3) based on the type of the current <code>SelectedSubView</code>.</p> <hr> <p>Since you only want to hide inactive Views, it's probably best to keep their respective ViewModels around, so you may want to make them fields in the <code>UC</code> class</p> <pre><code>public class UC { private MyFirstViewModel vm1; private MySecondViewModel vm2; private MyThirdViewModel vm3; private object selectedVM; public object SelectedSubView { get { return this.selectedVM; } } // This method should be called whenever one of the radio buttons // are updated (from their bindings) private void UpdateSelectedView() { this.selectedVM = // pick from vm1, vm2, vm3 according to radio button // Remember to raise INotifyPropertyChanged for SelectedSubView } } </code></pre>
    singulars
    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. 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.
 

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