0

I have a simple question, but for some reason I can't really find an appropriate answer.

In my application I have the following section:

  • a toolbar section (left dock)
  • a message section (bottom dock)
  • a navigation section (fill dock)

In the navigation section I want to show different user controls, depending on which button is pressed in the toolbar.

I have everything in place, but the navigation section always shows a hard-coded user control. I want to show user controls based on the button I pressed.

<DockPanel>
    <controls:MainActionBar DockPanel.Dock="Left" DataContext="{Binding MainActionBarViewModel}"/>
    <controls:Messages DockPanel.Dock="Bottom" />
    <!-- This is where some kind of navigation pane should be at -->
    <controls:SystemPCControl DataContext="{Binding SystemPCViewModel}"/>
</DockPanel>

I read all kinds of solutions, varying from Frame, to ContentView combined with ContentPresenter, to juggling visibility settings using Converters.

Google brings me to some heavy weight solution here.

Did I just run into something far from trivial to achieve in WPF? What's the way to go here? All I want is to show a user control based on the button I pressed.

bas
  • 13,550
  • 20
  • 69
  • 146
  • Show us the implementation of the SystemPCViewModel property, specifically the setter. – H H Apr 26 '15 at 20:25
  • @HenkHolterman, It's just an auto property, I got nothing of interest yet wrt navigation panel, I have no idea which path to follow. – bas Apr 26 '15 at 20:28
  • _It's just an auto property_ : that's the problem. It should raise the event from INotifyPropertyChanged. And then your ViewModel only has to assign the right data to it. – H H Apr 26 '15 at 20:38
  • Closed. See [my answer](http://stackoverflow.com/a/18539966/643085) in the duplicate question. What you need is a `TabControl`. – Federico Berasategui Apr 27 '15 at 03:32
  • @highcore of course... Why didn't i see that... Thx – bas Apr 27 '15 at 04:37
  • Found what I was looking for, can post the actual answer to this question for other readers if re-opened. – bas Apr 27 '15 at 09:06
  • @bas Is your answer different than the ones on the linked duplicate question? – Praxis Ashelin Apr 27 '15 at 09:56
  • @DarkAshelin, yes, without using a tabcontrol, a rather simple implementation with a `ContentControl`. – bas Apr 28 '15 at 06:33
  • The problem description of the duplicate question seems essentially the same as in your own question. If you disagree, please edit your question so that it is clear why this is actually a whole new question. If you agree that the question is basically the same, but you have a different _answer_, please add your answer to that question rather than trying to have this question reopened. – Peter Duniho May 03 '15 at 03:13
  • @PeterDuniho, that makes sense :). Added my answer in duplicate question. Thx for the explanation – bas May 04 '15 at 18:45

0 Answers0