kategorie fix highlight current value
This commit is contained in:
@@ -115,6 +115,7 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
searchTextBox?.Focus();
|
||||
searchTextBox?.SelectAll();
|
||||
suppressTreeSelectionChanged = false;
|
||||
SyncTreeSelectionWithSelectedItem(bringIntoView: true);
|
||||
LogEntry($"[CategoryPicker] DropDownOpened. Selected={SelectedItem?.FullPath ?? "<null>"}");
|
||||
DropDownOpened?.Invoke(this, e);
|
||||
}
|
||||
@@ -203,6 +204,7 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
}
|
||||
|
||||
TryExpandToSelectedItem();
|
||||
SyncTreeSelectionWithSelectedItem(bringIntoView: false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -220,6 +222,9 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
clone.SetExpandedRecursive(true);
|
||||
visibleItems.Add(clone);
|
||||
}
|
||||
|
||||
// If the selected item is part of current results, keep it visually selected.
|
||||
SyncTreeSelectionWithSelectedItem(bringIntoView: false);
|
||||
}
|
||||
|
||||
private void TryExpandToSelectedItem()
|
||||
@@ -238,6 +243,93 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
}
|
||||
}
|
||||
|
||||
private void SyncTreeSelectionWithSelectedItem(bool bringIntoView)
|
||||
{
|
||||
if (SelectedItem == null || string.IsNullOrWhiteSpace(SelectedItem.Id))
|
||||
return;
|
||||
|
||||
EnsureTemplateParts();
|
||||
if (treeViewControl == null)
|
||||
return;
|
||||
|
||||
// Wait for popup/template layout to finish so item containers are generated.
|
||||
Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
var target = FindVisibleItemById(VisibleItems, SelectedItem.Id);
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
var ancestor = target.Parent;
|
||||
while (ancestor != null)
|
||||
{
|
||||
ancestor.IsExpanded = true;
|
||||
ancestor = ancestor.Parent;
|
||||
}
|
||||
|
||||
treeViewControl.UpdateLayout();
|
||||
var targetContainer = GetTreeViewItemContainer(treeViewControl, target);
|
||||
if (targetContainer == null)
|
||||
return;
|
||||
|
||||
suppressTreeSelectionChanged = true;
|
||||
try
|
||||
{
|
||||
targetContainer.IsSelected = true;
|
||||
if (bringIntoView)
|
||||
targetContainer.BringIntoView();
|
||||
}
|
||||
finally
|
||||
{
|
||||
suppressTreeSelectionChanged = false;
|
||||
}
|
||||
}), DispatcherPriority.Loaded);
|
||||
}
|
||||
|
||||
private static HierarchicalSelectionItem FindVisibleItemById(IEnumerable<HierarchicalSelectionItem> items, string id)
|
||||
{
|
||||
if (items == null || string.IsNullOrWhiteSpace(id))
|
||||
return null;
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
if (item == null)
|
||||
continue;
|
||||
|
||||
if (string.Equals(item.Id, id, StringComparison.OrdinalIgnoreCase))
|
||||
return item;
|
||||
|
||||
var childMatch = FindVisibleItemById(item.Children, id);
|
||||
if (childMatch != null)
|
||||
return childMatch;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static TreeViewItem GetTreeViewItemContainer(ItemsControl root, object targetItem)
|
||||
{
|
||||
if (root == null || targetItem == null)
|
||||
return null;
|
||||
|
||||
var directContainer = root.ItemContainerGenerator.ContainerFromItem(targetItem) as TreeViewItem;
|
||||
if (directContainer != null)
|
||||
return directContainer;
|
||||
|
||||
foreach (var child in root.Items)
|
||||
{
|
||||
var childContainer = root.ItemContainerGenerator.ContainerFromItem(child) as TreeViewItem;
|
||||
if (childContainer == null)
|
||||
continue;
|
||||
|
||||
childContainer.UpdateLayout();
|
||||
var result = GetTreeViewItemContainer(childContainer, targetItem);
|
||||
if (result != null)
|
||||
return result;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void EnsureTemplateParts()
|
||||
{
|
||||
if (treeViewControl == null)
|
||||
|
||||
@@ -1,29 +1,30 @@
|
||||
<settingspagebase:SettingsPageBase
|
||||
xmlns:settingspagebase="clr-namespace:FasdDesktopUi.Pages.SettingsPage"
|
||||
x:Class="FasdDesktopUi.Pages.SettingsPage.SettingsPageView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:FasdDesktopUi.Pages.SettingsPage"
|
||||
xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
|
||||
xmlns:vc="clr-namespace:FasdDesktopUi.Basics.Converter"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
mc:Ignorable="d"
|
||||
Title="SettingsPageView"
|
||||
ResizeMode="NoResize"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
MinHeight="100"
|
||||
MinWidth="400"
|
||||
ShowInTaskbar="False"
|
||||
Topmost="True"
|
||||
SizeToContent="WidthAndHeight"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Initialized="Window_Initialized"
|
||||
x:Name="SettingsWindow"
|
||||
KeyDown="SettingsWindow_KeyDown" Closed="SettingsWindow_Closed" IsVisibleChanged="SettingsWindow_IsVisibleChanged">
|
||||
<settingspagebase:SettingsPageBase xmlns:settingspagebase="clr-namespace:FasdDesktopUi.Pages.SettingsPage"
|
||||
x:Class="FasdDesktopUi.Pages.SettingsPage.SettingsPageView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:FasdDesktopUi.Pages.SettingsPage"
|
||||
xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
|
||||
xmlns:vc="clr-namespace:FasdDesktopUi.Basics.Converter"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
mc:Ignorable="d"
|
||||
Title="SettingsPageView"
|
||||
ResizeMode="NoResize"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
MinHeight="100"
|
||||
MinWidth="400"
|
||||
ShowInTaskbar="False"
|
||||
Topmost="True"
|
||||
SizeToContent="WidthAndHeight"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Initialized="Window_Initialized"
|
||||
x:Name="SettingsWindow"
|
||||
KeyDown="SettingsWindow_KeyDown"
|
||||
Closed="SettingsWindow_Closed"
|
||||
IsVisibleChanged="SettingsWindow_IsVisibleChanged">
|
||||
|
||||
<settingspagebase:SettingsPageBase.Resources>
|
||||
<vc:LanguageDefinitionsConverter x:Key="LanguageConverter" />
|
||||
@@ -203,25 +204,39 @@
|
||||
SelectedCountryCode="GB" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel x:Name="ShouldSkipSlimViewLabel" Orientation="Horizontal">
|
||||
<StackPanel x:Name="ShouldSkipSlimViewLabel"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Menu.ShouldSkipSlimView}" />
|
||||
<ico:AdaptableIcon x:Name="ShouldSkipSlimViewPolicy" SelectedInternIcon="lock_closed" Margin="-25,-5,0,0" IconWidth="23" IconHeight="23" Visibility="Collapsed"/>
|
||||
<ico:AdaptableIcon x:Name="ShouldSkipSlimViewPolicy"
|
||||
SelectedInternIcon="lock_closed"
|
||||
PrimaryIconColor="{DynamicResource Color.Menu.Icon}"
|
||||
Margin="-25,-5,0,0"
|
||||
IconWidth="23"
|
||||
IconHeight="23"
|
||||
Visibility="Collapsed" />
|
||||
</StackPanel>
|
||||
|
||||
<CheckBox x:Name="ShouldSkipSlimViewCheckBox"
|
||||
Style="{DynamicResource ToggleSwitch}"
|
||||
IsChecked="{Binding ElementName=SettingsWindow, Path=ShouldSkipSlimView}"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="0,3,0,10"
|
||||
>
|
||||
Margin="0,3,0,10">
|
||||
</CheckBox>
|
||||
|
||||
<StackPanel x:Name="PositionOfSmallViewsLabel" Orientation="Horizontal">
|
||||
<StackPanel x:Name="PositionOfSmallViewsLabel"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Menu.PositionOfSmallViews}" />
|
||||
<ico:AdaptableIcon x:Name="PositionOfSmallViewsPolicy" SelectedInternIcon="lock_closed" Margin="-25,-5,0,0" IconWidth="23" IconHeight="23" Visibility="Collapsed"/>
|
||||
<ico:AdaptableIcon x:Name="PositionOfSmallViewsPolicy"
|
||||
SelectedInternIcon="lock_closed"
|
||||
PrimaryIconColor="{DynamicResource Color.Menu.Icon}"
|
||||
Margin="-25,-5,0,0"
|
||||
IconWidth="23"
|
||||
IconHeight="23"
|
||||
Visibility="Collapsed" />
|
||||
</StackPanel>
|
||||
|
||||
<Grid x:Name="PositionOfSmallViewsInput" Grid.IsSharedSizeScope="True"
|
||||
<Grid x:Name="PositionOfSmallViewsInput"
|
||||
Grid.IsSharedSizeScope="True"
|
||||
HorizontalAlignment="Left">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"
|
||||
@@ -269,12 +284,20 @@
|
||||
|
||||
</Grid>
|
||||
|
||||
<StackPanel x:Name="PositionOfFavouriteBarLabel" Orientation="Horizontal">
|
||||
<StackPanel x:Name="PositionOfFavouriteBarLabel"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Menu.PositionOfFavouriteBar}" />
|
||||
<ico:AdaptableIcon x:Name="PositionOfFavouriteBarPolicy" SelectedInternIcon="lock_closed" Margin="-25,-5,0,0" IconWidth="23" IconHeight="23" Visibility="Collapsed"/>
|
||||
<ico:AdaptableIcon x:Name="PositionOfFavouriteBarPolicy"
|
||||
SelectedInternIcon="lock_closed"
|
||||
PrimaryIconColor="{DynamicResource Color.Menu.Icon}"
|
||||
Margin="-25,-5,0,0"
|
||||
IconWidth="23"
|
||||
IconHeight="23"
|
||||
Visibility="Collapsed" />
|
||||
</StackPanel>
|
||||
|
||||
<Grid x:Name="PositionOfFavouriteBarInput" Grid.IsSharedSizeScope="True"
|
||||
<Grid x:Name="PositionOfFavouriteBarInput"
|
||||
Grid.IsSharedSizeScope="True"
|
||||
HorizontalAlignment="Left">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"
|
||||
|
||||
Reference in New Issue
Block a user