Skip to content

Commit 55788e8

Browse files
authored
Merge pull request #5037 from IvenBach/Issue4798_ReferenceExplorerAssemblyPathUpdatingUI
Synchronize reference explorer with selected item
2 parents ece4060 + 7569ee1 commit 55788e8

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed

Rubberduck.Core/UI/AddRemoveReferences/AddRemoveReferencesWindow.xaml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@
181181
SelectionMode="Single"
182182
ItemsSource="{Binding AvailableReferences}"
183183
HorizontalContentAlignment="Stretch"
184-
ScrollViewer.HorizontalScrollBarVisibility="Auto">
184+
ScrollViewer.HorizontalScrollBarVisibility="Auto"
185+
GotFocus="ListView_SynchronizeCurrentSelection_OnGotFocus">
185186
<ListView.ItemContainerStyle>
186187
<Style TargetType="ListViewItem">
187188
<Setter Property="Height" Value="20" />
@@ -239,7 +240,8 @@
239240
SelectionMode="Single"
240241
ItemsSource="{Binding ProjectReferences, NotifyOnTargetUpdated=True}"
241242
ScrollViewer.HorizontalScrollBarVisibility="Auto"
242-
HorizontalContentAlignment="Stretch">
243+
HorizontalContentAlignment="Stretch"
244+
GotFocus="ListView_SynchronizeCurrentSelection_OnGotFocus">
243245
<ListView.ItemContainerStyle>
244246
<Style TargetType="ListViewItem">
245247
<Setter Property="Height" Value="20" />
@@ -388,18 +390,22 @@
388390
<ColumnDefinition Width="50" />
389391
<ColumnDefinition Width="100" />
390392
</Grid.ColumnDefinitions>
391-
<TextBox Grid.Row="0" Grid.Column="0" Style="{StaticResource SelectableText}" Text="{Binding CurrentSelection.Description, Mode=OneWay}" />
393+
<TextBox x:Name="Description"
394+
Grid.Row="0" Grid.Column="0" Style="{StaticResource SelectableText}" Text="{Binding CurrentSelection.Description, Mode=OneWay}" />
392395
<Label Grid.Row="0" Grid.Column="1"
393396
Foreground="{x:Static SystemColors.GrayTextBrush}"
394397
VerticalAlignment="Center"
395398
Content="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=References_Version}" />
396-
<TextBox Grid.Row="0" Grid.Column="2" Style="{StaticResource SelectableText}" Text="{Binding CurrentSelection.Version, Mode=OneWay}" />
399+
<TextBox x:Name="Version"
400+
Grid.Row="0" Grid.Column="2" Style="{StaticResource SelectableText}" Text="{Binding CurrentSelection.Version, Mode=OneWay}" />
397401
<Label Grid.Row="0" Grid.Column="3"
398402
Foreground="{x:Static SystemColors.GrayTextBrush}"
399403
VerticalAlignment="Center"
400404
Content="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=References_Locale}" />
401-
<TextBox Grid.Row="0" Grid.Column="4" Style="{StaticResource SelectableText}" Text="{Binding CurrentSelection.LocaleName, Mode=OneWay}" />
402-
<TextBox Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="5" Style="{StaticResource SelectableText}" Text="{Binding CurrentSelection.FullPath, Mode=OneWay}" />
405+
<TextBox x:Name="LocaleName"
406+
Grid.Row="0" Grid.Column="4" Style="{StaticResource SelectableText}" Text="{Binding CurrentSelection.LocaleName, Mode=OneWay}" />
407+
<TextBox x:Name="FullPath"
408+
Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="5" Style="{StaticResource SelectableText}" Text="{Binding CurrentSelection.FullPath, Mode=OneWay}" />
403409
</Grid>
404410
</Border>
405411
</Border>
Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,36 @@
1-
using System.Windows.Controls;
1+
using System.Windows;
2+
using System.Windows.Controls.Primitives;
3+
using Rubberduck.AddRemoveReferences;
24

35
namespace Rubberduck.UI.AddRemoveReferences
46
{
57
/// <summary>
68
/// Interaction logic for AddRemoveReferencesWindow.xaml
79
/// </summary>
8-
public partial class AddRemoveReferencesWindow : UserControl
10+
public partial class AddRemoveReferencesWindow
911
{
1012
public AddRemoveReferencesWindow()
1113
{
1214
InitializeComponent();
1315
}
1416

1517
private AddRemoveReferencesViewModel ViewModel => DataContext as AddRemoveReferencesViewModel;
18+
19+
private void ListView_SynchronizeCurrentSelection_OnGotFocus(object sender, RoutedEventArgs e)
20+
{
21+
UpdateCurrentSelection((Selector)sender);
22+
23+
var cs = ViewModel.CurrentSelection;
24+
Description.Text = cs.Description;
25+
Version.Text = cs.Version;
26+
LocaleName.Text = cs.LocaleName;
27+
FullPath.Text = cs.FullPath;
28+
}
29+
30+
private void UpdateCurrentSelection(Selector sender)
31+
{
32+
var selectedReferenceModel = (ReferenceModel)sender.SelectedItem;
33+
ViewModel.CurrentSelection = selectedReferenceModel;
34+
}
1635
}
1736
}

0 commit comments

Comments
 (0)