Skip to content

Commit ff5e31a

Browse files
committed
Fix fix menu in inspection results window
The relative source, which works for the context menu, does not for the toolbar menu because the grouping grid is in another branch of the logical tree. Instead, the grouping grid can be referred by name, which does not work for the grouping grid's context menu. Accordingly, a solution with a fallback is employed.
1 parent 1141a33 commit ff5e31a

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Rubberduck.Core/UI/Inspections/InspectionResultsControl.xaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
<Setter.Value>
3131
<MultiBinding Converter="{StaticResource QuickFixCommandParametersToTupleConverter}">
3232
<Binding Path="Fix" />
33-
<Binding Path="SelectedItems" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type controls:GroupingGrid}}" />
33+
<Binding ElementName="InspectionResultsGrid" Path="SelectedItems" />
34+
<!-- This is a hack to deal with the fact that a named element on the control cannot be accessed from the context menu of the element by name. -->
35+
<Binding Path="SelectedItems" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type controls:GroupingGrid}}" />
3436
</MultiBinding>
3537
</Setter.Value>
3638
</Setter>

Rubberduck.Core/UI/Inspections/QuickFixCommandParametersToTupleConverter.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,15 @@ public class QuickFixCommandParametersToTupleConverter : IMultiValueConverter
1313
{
1414
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
1515
{
16+
//Note: this is necessary for a hack dealing with the fact that a named element on the control cannot be accessed from the context menu of the element by name.
17+
var selectedItems = values[1] as IEnumerable
18+
?? values[2] as IEnumerable
19+
?? new List<IInspectionResult>();
20+
1621
(IQuickFix quickFix, IEnumerable<IInspectionResult> selectedResults) data = (
1722
values[0] as IQuickFix,
18-
((IEnumerable)values[1]).OfType<IInspectionResult>());
23+
selectedItems.OfType<IInspectionResult>());
24+
1925
return data;
2026
}
2127

0 commit comments

Comments
 (0)