Skip to content

Commit 7baf5fb

Browse files
committed
Bind directly to VM, removes last of the leaked bindings.
1 parent 39da95b commit 7baf5fb

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

Rubberduck.Core/UI/Inspections/InspectionResultsControl.xaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,12 @@
235235
<ColumnDefinition />
236236
</Grid.ColumnDefinitions>
237237
<Image Style="{StaticResource IconMargin}" VerticalAlignment="Top" Grid.Column="0"
238-
Source="{Binding SelectedItem.Inspection.Severity, Converter={StaticResource SeverityIconConverter}}"/>
239-
<TextBlock Grid.Column="1" Margin="4" Text="{Binding SelectedItem.Inspection.Description}" FontWeight="Bold" TextWrapping="WrapWithOverflow"/>
238+
Source="{Binding SelectedSeverity, Converter={StaticResource SeverityIconConverter}}"/>
239+
<TextBlock Grid.Column="1" Margin="4" Text="{Binding SelectedDescription}" FontWeight="Bold" TextWrapping="WrapWithOverflow"/>
240240
</Grid>
241241

242-
<TextBlock Margin="4" Text="{Binding SelectedItem.Inspection.Meta}" FontSize="10" TextWrapping="WrapWithOverflow"/>
243-
<TextBlock Margin="8" Text="{Binding SelectedItem.QualifiedSelection}" FontSize="10" TextWrapping="WrapWithOverflow" />
242+
<TextBlock Margin="4" Text="{Binding SelectedMeta}" FontSize="10" TextWrapping="WrapWithOverflow"/>
243+
<TextBlock Margin="8" Text="{Binding SelectedSelection}" FontSize="10" TextWrapping="WrapWithOverflow" />
244244

245245
<WrapPanel>
246246
<controls:LinkButton Margin="4"

Rubberduck.Core/UI/Inspections/InspectionResultsViewModel.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using Rubberduck.UI.Command;
1919
using Rubberduck.UI.Controls;
2020
using Rubberduck.UI.Settings;
21+
using Rubberduck.VBEditor;
2122

2223
namespace Rubberduck.UI.Inspections
2324
{
@@ -140,6 +141,9 @@ public INavigateSource SelectedItem
140141
_selectedItem = value;
141142
OnPropertyChanged();
142143
OnPropertyChanged(nameof(QuickFixes));
144+
OnPropertyChanged(nameof(SelectedDescription));
145+
OnPropertyChanged(nameof(SelectedMeta));
146+
OnPropertyChanged(nameof(SelectedSeverity));
143147

144148
SelectedInspection = null;
145149
CanQuickFix = false;
@@ -150,6 +154,8 @@ public INavigateSource SelectedItem
150154
if (_selectedItem is IInspectionResult inspectionResult)
151155
{
152156
SelectedInspection = inspectionResult.Inspection;
157+
SelectedSelection = inspectionResult.QualifiedSelection;
158+
153159
CanQuickFix = _quickFixProvider.HasQuickFixes(inspectionResult);
154160
_defaultFix = _quickFixProvider.QuickFixes(inspectionResult).FirstOrDefault();
155161
CanExecuteQuickFixInProcedure = _defaultFix != null && _defaultFix.CanFixInProcedure;
@@ -170,9 +176,18 @@ public IInspection SelectedInspection
170176
{
171177
_selectedInspection = value;
172178
OnPropertyChanged();
179+
OnPropertyChanged(nameof(SelectedSelection));
173180
}
174181
}
175182

183+
public string SelectedDescription => SelectedInspection?.Description ?? string.Empty;
184+
185+
public string SelectedMeta => SelectedInspection?.Meta ?? string.Empty;
186+
187+
public CodeInspectionSeverity SelectedSeverity => SelectedInspection?.Severity ?? CodeInspectionSeverity.DoNotShow;
188+
189+
public QualifiedSelection SelectedSelection { get; private set; }
190+
176191
public IEnumerable<DisplayQuickFix> QuickFixes
177192
{
178193
get

Rubberduck.Core/UI/Inspections/InspectionSeverityImageSourceConverter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class InspectionSeverityImageSourceConverter : IValueConverter
1717
private static readonly IDictionary<CodeInspectionSeverity,ImageSource> Icons =
1818
new Dictionary<CodeInspectionSeverity, ImageSource>
1919
{
20+
{ CodeInspectionSeverity.DoNotShow, null },
2021
{ CodeInspectionSeverity.Hint, ToImageSource(InspectionsUI.information_white) },
2122
{ CodeInspectionSeverity.Suggestion, ToImageSource(InspectionsUI.information) },
2223
{ CodeInspectionSeverity.Warning, ToImageSource(InspectionsUI.exclamation) },

0 commit comments

Comments
 (0)