I have this:
<igWPF:XamOutlookBar Grid.Row="1" Grid.Column="0"> <i:Interaction.Triggers> <i:EventTrigger EventName="SelectedGroupChanged" > <i:InvokeCommandAction Command="{Binding OnBarGroupChangeCommand}" CommandParameter="{Binding ElementName=xamOutlookBar, Path=SelectedGroup.Name}" /> </i:EventTrigger> </i:Interaction.Triggers>
And I have two groups -> LogsBarGroup and ReportsBarGroup. Both of these contain a XamDataTree control. For each data tree I also have a trigger:
<i:Interaction.Triggers> <i:EventTrigger EventName="ActiveNodeChanged" > <i:InvokeCommandAction Command="{Binding OnReportSelectionCommand}" CommandParameter="{Binding ElementName=ReportsTreeTree, Path=ActiveNode.Data.ReportID }" /> </i:EventTrigger> </i:Interaction.Triggers>
What I'm trying to do is pass back the selected groups Name.
When I use the SelectedGroupChanged event it passes back the name of the group that was already selected and not the one I clicked on. When I use the event LeftMouseButtonUp it passes back the correct bar group name BUT when i click on a node in the tree it fires the ActiveNodeChanged event AND right after the LeftMouseButtonUp of the XamOutlookBar evant as well. What event can I use so that the correct bar group name gets passed when I click on a bar group button but does not fire that same event when I click on a node in the XamDataTree.
Thanks
Hello Kris,
SelectedGroupChanged would be the ideal event for this. The issue is that because there's a binding on the CommandParameter, it causes a timing issue where the event fires but the binding hasn't been updated yet via property change notifications so the command ends up with the old value. You can actually see the timing if you place a converter in the binding and bind directly to SelectedGroup. The converter's Convert method will execute when it detects that the property has changed. What I saw was the Convert method didn't execute until AFTER the command was fired.
What I recommend doing is using the MVVM Light EventToCommand object and setting PassEventArgsToCommand to true. This will pass the event arguments of the event to the command. Inside the arguments you will see properties for NewSelectedOutlookBarGroup and PreviousSelectedOutlookBarGroup.
http://help.infragistics.com/doc/WPF/2014.1/CLR4.0/?page=InfragisticsWPF4.OutlookBar.v14.1~Infragistics.Windows.OutlookBar.Events.SelectedGroupChangedEventArgs_members.html
<igWPF:XamOutlookBar> <i:Interaction.Triggers> <i:EventTrigger EventName="SelectedGroupChanged"> <mvvmlight:EventToCommand Command="{Binding OnBarGroupChangeCommand}" PassEventArgsToCommand="True"/> </i:EventTrigger> </i:Interaction.Triggers> </igWPF:XamOutlookBar>
That's what I was looking for. Thanks!