Skip to content

Commit beae839

Browse files
SLVS-2522 Add workaround that allows showing the server in which the hotspot can be viewed in browser
1 parent 0ccb3a3 commit beae839

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/IssueViz.Security/ReportView/ReportViewControl.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@
197197
Click="ChangeHotspotStatusMenuItem_OnClick"
198198
Style="{StaticResource ChangeStatusMenuItemStyle}"/>
199199
<MenuItem Click="ViewHotspotInBrowser_OnClick"
200-
Header="{x:Static res:Resources.ViewHotspotInBrowser}"
200+
Loaded="ShowHotspotInBrowserMenuItem_OnLoaded"
201201
Style="{StaticResource ViewIssueInBrowserMenuItemStyle}" />
202202
</ContextMenu>
203203

src/IssueViz.Security/ReportView/ReportViewControl.xaml.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,20 @@ private void ViewDependencyRiskInBrowser_OnClick(object sender, RoutedEventArgs
116116
DependencyRisksReportViewModel.ShowDependencyRiskInBrowser(selectedDependencyRiskViewModel.DependencyRisk);
117117
}
118118

119-
private void DependencyRiskContextMenu_OnLoaded(object sender, RoutedEventArgs e)
119+
private void DependencyRiskContextMenu_OnLoaded(object sender, RoutedEventArgs e) => SetDataContextToReportViewModel<ContextMenu>(sender);
120+
121+
private void SetDataContextToReportViewModel<T>(object sender) where T : FrameworkElement
120122
{
121-
if (sender is ContextMenu contextMenu)
123+
if (sender is T contextMenu)
122124
{
123-
// setting the DataContext directly on the context menu does not work for the TreeViewItem
125+
// workaround that allows setting the DataContext to the ReportViewModel, which is not accessible from the TreeViewItem context menu
126+
// due to the fact that a context menu is a popup and is not part of the visual tree
124127
contextMenu.DataContext = ReportViewModel;
125128
}
126129
}
127130

131+
private void ShowHotspotInBrowserMenuItem_OnLoaded(object sender, RoutedEventArgs e) => SetDataContextToReportViewModel<MenuItem>(sender);
132+
128133
private void TreeViewItem_OnMouseRightButtonDown(object sender, MouseButtonEventArgs e)
129134
{
130135
if (sender is FrameworkElement element && FindParentOfType<TreeViewItem>(element) is { } treeViewItem)

0 commit comments

Comments
 (0)