kategorie fix highlight current value
This commit is contained in:
@@ -115,6 +115,7 @@ namespace FasdDesktopUi.Basics.UserControls
|
|||||||
searchTextBox?.Focus();
|
searchTextBox?.Focus();
|
||||||
searchTextBox?.SelectAll();
|
searchTextBox?.SelectAll();
|
||||||
suppressTreeSelectionChanged = false;
|
suppressTreeSelectionChanged = false;
|
||||||
|
SyncTreeSelectionWithSelectedItem(bringIntoView: true);
|
||||||
LogEntry($"[CategoryPicker] DropDownOpened. Selected={SelectedItem?.FullPath ?? "<null>"}");
|
LogEntry($"[CategoryPicker] DropDownOpened. Selected={SelectedItem?.FullPath ?? "<null>"}");
|
||||||
DropDownOpened?.Invoke(this, e);
|
DropDownOpened?.Invoke(this, e);
|
||||||
}
|
}
|
||||||
@@ -203,6 +204,7 @@ namespace FasdDesktopUi.Basics.UserControls
|
|||||||
}
|
}
|
||||||
|
|
||||||
TryExpandToSelectedItem();
|
TryExpandToSelectedItem();
|
||||||
|
SyncTreeSelectionWithSelectedItem(bringIntoView: false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,6 +222,9 @@ namespace FasdDesktopUi.Basics.UserControls
|
|||||||
clone.SetExpandedRecursive(true);
|
clone.SetExpandedRecursive(true);
|
||||||
visibleItems.Add(clone);
|
visibleItems.Add(clone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the selected item is part of current results, keep it visually selected.
|
||||||
|
SyncTreeSelectionWithSelectedItem(bringIntoView: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TryExpandToSelectedItem()
|
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()
|
private void EnsureTemplateParts()
|
||||||
{
|
{
|
||||||
if (treeViewControl == null)
|
if (treeViewControl == null)
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<settingspagebase:SettingsPageBase
|
<settingspagebase:SettingsPageBase xmlns:settingspagebase="clr-namespace:FasdDesktopUi.Pages.SettingsPage"
|
||||||
xmlns:settingspagebase="clr-namespace:FasdDesktopUi.Pages.SettingsPage"
|
|
||||||
x:Class="FasdDesktopUi.Pages.SettingsPage.SettingsPageView"
|
x:Class="FasdDesktopUi.Pages.SettingsPage.SettingsPageView"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
@@ -23,7 +22,9 @@
|
|||||||
WindowStartupLocation="CenterScreen"
|
WindowStartupLocation="CenterScreen"
|
||||||
Initialized="Window_Initialized"
|
Initialized="Window_Initialized"
|
||||||
x:Name="SettingsWindow"
|
x:Name="SettingsWindow"
|
||||||
KeyDown="SettingsWindow_KeyDown" Closed="SettingsWindow_Closed" IsVisibleChanged="SettingsWindow_IsVisibleChanged">
|
KeyDown="SettingsWindow_KeyDown"
|
||||||
|
Closed="SettingsWindow_Closed"
|
||||||
|
IsVisibleChanged="SettingsWindow_IsVisibleChanged">
|
||||||
|
|
||||||
<settingspagebase:SettingsPageBase.Resources>
|
<settingspagebase:SettingsPageBase.Resources>
|
||||||
<vc:LanguageDefinitionsConverter x:Key="LanguageConverter" />
|
<vc:LanguageDefinitionsConverter x:Key="LanguageConverter" />
|
||||||
@@ -203,25 +204,39 @@
|
|||||||
SelectedCountryCode="GB" />
|
SelectedCountryCode="GB" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<StackPanel x:Name="ShouldSkipSlimViewLabel" Orientation="Horizontal">
|
<StackPanel x:Name="ShouldSkipSlimViewLabel"
|
||||||
|
Orientation="Horizontal">
|
||||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Menu.ShouldSkipSlimView}" />
|
<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>
|
</StackPanel>
|
||||||
|
|
||||||
<CheckBox x:Name="ShouldSkipSlimViewCheckBox"
|
<CheckBox x:Name="ShouldSkipSlimViewCheckBox"
|
||||||
Style="{DynamicResource ToggleSwitch}"
|
Style="{DynamicResource ToggleSwitch}"
|
||||||
IsChecked="{Binding ElementName=SettingsWindow, Path=ShouldSkipSlimView}"
|
IsChecked="{Binding ElementName=SettingsWindow, Path=ShouldSkipSlimView}"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
Margin="0,3,0,10"
|
Margin="0,3,0,10">
|
||||||
>
|
|
||||||
</CheckBox>
|
</CheckBox>
|
||||||
|
|
||||||
<StackPanel x:Name="PositionOfSmallViewsLabel" Orientation="Horizontal">
|
<StackPanel x:Name="PositionOfSmallViewsLabel"
|
||||||
|
Orientation="Horizontal">
|
||||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Menu.PositionOfSmallViews}" />
|
<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>
|
</StackPanel>
|
||||||
|
|
||||||
<Grid x:Name="PositionOfSmallViewsInput" Grid.IsSharedSizeScope="True"
|
<Grid x:Name="PositionOfSmallViewsInput"
|
||||||
|
Grid.IsSharedSizeScope="True"
|
||||||
HorizontalAlignment="Left">
|
HorizontalAlignment="Left">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto"
|
<ColumnDefinition Width="Auto"
|
||||||
@@ -269,12 +284,20 @@
|
|||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<StackPanel x:Name="PositionOfFavouriteBarLabel" Orientation="Horizontal">
|
<StackPanel x:Name="PositionOfFavouriteBarLabel"
|
||||||
|
Orientation="Horizontal">
|
||||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Menu.PositionOfFavouriteBar}" />
|
<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>
|
</StackPanel>
|
||||||
|
|
||||||
<Grid x:Name="PositionOfFavouriteBarInput" Grid.IsSharedSizeScope="True"
|
<Grid x:Name="PositionOfFavouriteBarInput"
|
||||||
|
Grid.IsSharedSizeScope="True"
|
||||||
HorizontalAlignment="Left">
|
HorizontalAlignment="Left">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto"
|
<ColumnDefinition Width="Auto"
|
||||||
|
|||||||
Reference in New Issue
Block a user