summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/Views
diff options
context:
space:
mode:
authorsr55 <[email protected]>2020-06-03 18:25:20 +0100
committersr55 <[email protected]>2020-06-03 18:25:30 +0100
commitcf8281966e0ff934b9c5728f82afe6ab08f61b28 (patch)
tree5fc2269f3cde96b21e52fbc7f91de890e57859c6 /win/CS/HandBrakeWPF/Views
parent769b48378969aa7cd927873804ab0ad4cb79e06e (diff)
WinGui: Fix an issue where the treeview control can, when categories are closed, trigger a series of events that cause the preset to be de-selected.
Fix an issue where removing a preset can leave none selected. #2875
Diffstat (limited to 'win/CS/HandBrakeWPF/Views')
-rw-r--r--win/CS/HandBrakeWPF/Views/MainView.xaml2
-rw-r--r--win/CS/HandBrakeWPF/Views/MainView.xaml.cs34
2 files changed, 25 insertions, 11 deletions
diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml b/win/CS/HandBrakeWPF/Views/MainView.xaml
index a57759a2a..20afae2a8 100644
--- a/win/CS/HandBrakeWPF/Views/MainView.xaml
+++ b/win/CS/HandBrakeWPF/Views/MainView.xaml
@@ -641,7 +641,7 @@
<TreeView x:Name="presetListTree" HorizontalAlignment="Stretch" AutomationProperties.Name="Presets List" ToolTip="{x:Static Properties:ResourcesTooltips.MainView_Presets}"
VerticalAlignment="Stretch" BorderThickness="0,0,0,1" BorderBrush="LightGray"
ItemsSource="{Binding PresetsCategories}" MaxWidth="265"
- helpers:TreeViewHelper.TreeViewSelectedItem="{Binding Path=SelectedPreset, Mode=TwoWay}"
+ SelectedItemChanged="PresetListTree_OnSelectedItemChanged"
PreviewMouseRightButtonDown="PresetListTree_OnPreviewMouseRightButtonDown">
<TreeView.ItemContainerStyle>
diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml.cs b/win/CS/HandBrakeWPF/Views/MainView.xaml.cs
index cdcbc65ef..b436bcca3 100644
--- a/win/CS/HandBrakeWPF/Views/MainView.xaml.cs
+++ b/win/CS/HandBrakeWPF/Views/MainView.xaml.cs
@@ -14,6 +14,7 @@ namespace HandBrakeWPF.Views
using System.Windows.Input;
using System.Windows.Media;
+ using HandBrakeWPF.Services.Presets.Model;
using HandBrakeWPF.ViewModels;
using HandBrakeWPF.ViewModels.Interfaces;
@@ -112,16 +113,6 @@ namespace HandBrakeWPF.Views
}
}
}
-
- private void PresetTreeviewItemCollasped(object sender, RoutedEventArgs e)
- {
- if (e.Source.GetType() == typeof(TreeViewItem))
- {
- TreeViewItem item = e.Source as TreeViewItem;
- if (item != null) item.IsSelected = false;
- }
- }
-
private void PresetListTree_OnPreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
TreeViewItem treeViewItem = VisualUpwardSearch(e.OriginalSource as DependencyObject);
@@ -140,5 +131,28 @@ namespace HandBrakeWPF.Views
return source as TreeViewItem;
}
+
+ private void PresetTreeviewItemCollasped(object sender, RoutedEventArgs e)
+ {
+ if (e.Source.GetType() == typeof(TreeViewItem))
+ {
+ TreeViewItem item = e.Source as TreeViewItem;
+ if (item != null && item.GetType() == typeof(PresetDisplayCategory))
+ {
+ item.IsSelected = false;
+ }
+ }
+ }
+
+ private void PresetListTree_OnSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
+ {
+ if (e.Source.GetType() == typeof(TreeView))
+ {
+ if (e.NewValue != null && e.NewValue.GetType() == typeof(Preset))
+ {
+ ((MainViewModel)this.DataContext).SelectedPreset = (Preset)e.NewValue;
+ }
+ }
+ }
}
}