140 lines
8.7 KiB
XML
140 lines
8.7 KiB
XML
<UserControl x:Class="FasdDesktopUi.Basics.UserControls.HierarchicalSelectionControl"
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
xmlns:local="clr-namespace:FasdDesktopUi.Basics.UserControls"
|
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
|
|
xmlns:vc="clr-namespace:FasdDesktopUi.Basics.Converter"
|
|
xmlns:models="clr-namespace:FasdDesktopUi.Basics.Models"
|
|
mc:Ignorable="d"
|
|
x:Name="HierarchySelector"
|
|
Focusable="True"
|
|
d:DesignHeight="60"
|
|
d:DesignWidth="350">
|
|
|
|
<UserControl.Resources>
|
|
<vc:LanguageDefinitionsConverter x:Key="LanguageConverter" />
|
|
<vc:NullValueToVisibilityConverter x:Key="NullToVisibility" />
|
|
|
|
<ControlTemplate x:Key="HierarchicalComboBoxTemplate"
|
|
TargetType="{x:Type ComboBox}">
|
|
<Grid>
|
|
<ToggleButton x:Name="toggleButton"
|
|
Grid.ColumnSpan="2"
|
|
Focusable="False"
|
|
ClickMode="Press"
|
|
IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
|
|
Background="{TemplateBinding Background}"
|
|
BorderBrush="{TemplateBinding BorderBrush}"
|
|
BorderThickness="{TemplateBinding BorderThickness}"
|
|
Style="{StaticResource ComboBoxToggleButton}" />
|
|
|
|
<ContentPresenter x:Name="contentPresenter"
|
|
IsHitTestVisible="False"
|
|
Content="{TemplateBinding SelectionBoxItem}"
|
|
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
|
|
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
|
|
Margin="6 0"
|
|
VerticalAlignment="Center"
|
|
HorizontalAlignment="Stretch" />
|
|
|
|
<Popup x:Name="PART_Popup"
|
|
Placement="Bottom"
|
|
PlacementTarget="{Binding ElementName=toggleButton}"
|
|
AllowsTransparency="True"
|
|
Focusable="False"
|
|
IsOpen="{TemplateBinding IsDropDownOpen}"
|
|
PopupAnimation="Fade">
|
|
<Border Width="{Binding ActualWidth, ElementName=HierarchySelector}"
|
|
Background="{DynamicResource BackgroundColor.Menu.SubCategory}"
|
|
CornerRadius="7.5"
|
|
Padding="10">
|
|
<Border.Effect>
|
|
<DropShadowEffect BlurRadius="10"
|
|
Color="{DynamicResource DropShadowColor.Menu}"
|
|
Direction="55"
|
|
ShadowDepth="10"
|
|
Opacity="0.35" />
|
|
</Border.Effect>
|
|
<StackPanel>
|
|
<Grid Margin="0 0 10 0">
|
|
<TextBox x:Name="PART_SearchTextBox"
|
|
Style="{DynamicResource Customizable.Editable.TextBox.EditOnly}"
|
|
Background="{TemplateBinding Background}"
|
|
Padding="27 5 5 5"
|
|
VerticalContentAlignment="Center" />
|
|
<ico:AdaptableIcon SelectedInternIcon="menuBar_search"
|
|
Style="{DynamicResource Menu.MenuBar.PinnedIcon.Base}"
|
|
BorderPadding="5 5 5 7"
|
|
Margin="0"
|
|
IconBackgroundColor="Transparent"
|
|
HorizontalAlignment="Left"
|
|
VerticalAlignment="Center" />
|
|
<TextBlock Margin="30 0 0 0"
|
|
Foreground="{DynamicResource FontColor.DetailsPage.DataHistory.Date}"
|
|
IsHitTestVisible="False"
|
|
VerticalAlignment="Center">
|
|
<TextBlock.Style>
|
|
<Style TargetType="TextBlock">
|
|
<Setter Property="Visibility" Value="Collapsed" />
|
|
<Style.Triggers>
|
|
<DataTrigger Binding="{Binding Text, ElementName=PART_SearchTextBox}"
|
|
Value="">
|
|
<Setter Property="Text"
|
|
Value="{Binding Path=SearchPlaceholderText, RelativeSource={RelativeSource AncestorType={x:Type local:HierarchicalSelectionControl}}}" />
|
|
<Setter Property="Visibility" Value="Visible" />
|
|
</DataTrigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
</TextBlock.Style>
|
|
</TextBlock>
|
|
</Grid>
|
|
|
|
<Border Margin="0 10 0 0"
|
|
Background="{DynamicResource BackgroundColor.Menu.SubCategory}"
|
|
BorderThickness="0"
|
|
CornerRadius="5">
|
|
<ScrollViewer MaxHeight="300"
|
|
VerticalScrollBarVisibility="Auto">
|
|
<TreeView x:Name="PART_TreeView"
|
|
Background="{DynamicResource BackgroundColor.Menu.SubCategory}"
|
|
ItemsSource="{Binding ItemsSource, RelativeSource={RelativeSource TemplatedParent}}">
|
|
<TreeView.Resources>
|
|
<Style TargetType="TreeViewItem">
|
|
<Setter Property="IsExpanded"
|
|
Value="{Binding IsExpanded, Mode=TwoWay}" />
|
|
</Style>
|
|
<HierarchicalDataTemplate DataType="{x:Type models:HierarchicalSelectionItem}"
|
|
ItemsSource="{Binding Children}">
|
|
<TextBlock Text="{Binding DisplayName}"
|
|
Foreground="{DynamicResource FontColor.Menu.Categories}"
|
|
Margin="0 2 0 2" />
|
|
</HierarchicalDataTemplate>
|
|
</TreeView.Resources>
|
|
</TreeView>
|
|
</ScrollViewer>
|
|
</Border>
|
|
</StackPanel>
|
|
</Border>
|
|
</Popup>
|
|
</Grid>
|
|
</ControlTemplate>
|
|
</UserControl.Resources>
|
|
|
|
<Grid>
|
|
<ComboBox x:Name="ComboBoxControl"
|
|
Background="{Binding ElementName=HierarchySelector, Path=ComboBoxBackground}"
|
|
BorderBrush="{Binding ElementName=HierarchySelector, Path=BorderBrush}"
|
|
Foreground="{DynamicResource FontColor.Menu.Categories}"
|
|
ItemsSource="{Binding VisibleItems, ElementName=HierarchySelector}"
|
|
SelectedItem="{Binding SelectedItem, ElementName=HierarchySelector, Mode=TwoWay}"
|
|
DisplayMemberPath="FullPath"
|
|
Template="{StaticResource HierarchicalComboBoxTemplate}"
|
|
DropDownOpened="ComboBoxControl_DropDownOpened"
|
|
DropDownClosed="ComboBoxControl_DropDownClosed"
|
|
IsEditable="False"
|
|
Padding="0" />
|
|
</Grid>
|
|
</UserControl>
|