Hello. I swap the content out using the <ContentControl> tag based on something click in the XamOutlookBar control. When I click on a particular OutlookBarGroup a command is sent to the view model to swap out the content in a certain part of the main window as per the code block below.
<ContentControl Content="{Binding CurrentPageViewModel}" Grid.Column="1" />
private void OnBarGroupClick(object barGroupKey){ if (barGroupKey.ToString() == "LogsBarGroupKey"){CurrentPageViewModel = _logsViewModel;}
So when clicking on bar group everything works fine. One of the bar groups contains a tree as so:
<TreeViewItem Header="Station Reporting" Name="StationReportingTree"> <TreeViewItem Name="VariousReportsItem" Header="REPORTS"/> </TreeViewItem>
When I click on the VariousReportsItem in the tree a command is sent to swap out the content since there will be various reports.
private void OnReportSelection(object treeViewItemName){ if (treeViewItemName != null){ if (treeViewItemName.ToString() == "VariousReportsItem"){ CurrentPageViewModel = _variousReportsViewModel;}} }
So I can see the OnReportsSelection method being reached and the CurrentPageViewModel = _variousReportsViewModel statement gets executed but the content does not get swapped out and I have no idea why.
I've included a sample project with this issue. Thanks.
Hi Kris,
Great. Glad Rob was able to help you with the MVVMLight event trigger solution.
Let me know if you have any questions.
Hello, the solutions was to use the mvvm light event trigger. I was suggegsted by one of your team members -> http://es.infragistics.com/community/forums/t/92016.aspx
Thanks.
Hi,
I hadn't heard back from you and I was wondering if you had further questions.
Please let me know if I can be any assistance.
That's what I was trying to explain, that both the tree and the outlook group events were being fired, so that the CurrentPageViewModel is be overridden by the outlook group.
I still believe that the solution might be to use a different event trigger for the TreeView or create a separate command for the ReportsBarGroup and keep track of whether you have just hit the treeview. One other solution might be to look into MVVM Light where you can pass event args to the command.
Let me know if this helps.
The problem turned out to be that when an TreeViewItem was clicked the event associated with that click would fire and the ContentControl would be set BUT also right after the event when a bar group was clicked also fired re-setting the view.