HashCalculator.GUI/InputBar.xaml
2020-04-03 04:48:57 +02:00

144 lines
6.2 KiB
XML

<UserControl
x:Class="HashCalculator.GUI.InputBar"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:HashCalculator.GUI"
xmlns:c="clr-namespace:HashCalculator.GUI.Converters"
mc:Ignorable="d"
x:ClassModifier="internal"
x:Name="Self"
d:DesignHeight="100" d:DesignWidth="800"
>
<UserControl.Resources>
<Style
x:Key="BlankListBoxContainerStyle"
TargetType="{x:Type ListBoxItem}"
>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Border
Name="Border"
Padding="3, 2"
SnapsToDevicePixels="true"
>
<ContentPresenter />
</Border>
<ControlTemplate.Triggers>
<Trigger
Property="IsSelected"
Value="true"
>
<Setter
TargetName="Border"
Property="Background"
Value="DarkSlateGray"
/>
<Setter
Property="Foreground"
Value="White"
/>
</Trigger>
<Trigger
Property="IsMouseOver"
Value="true"
>
<Setter
TargetName="Border"
Property="Background"
Value="DarkSlateGray"
/>
<Setter
Property="Foreground"
Value="White"
/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Grid>
<!--TextChanged="OnTextChanged"-->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="24"/>
</Grid.ColumnDefinitions>
<TextBox
x:Name="TextBox"
Text="{Binding Path=Text,
RelativeSource={RelativeSource AncestorType=local:InputBar},
UpdateSourceTrigger=PropertyChanged}"
PreviewKeyDown="OnPreviewKeyDown"
Grid.Column="0"
Padding="2, 0"
VerticalContentAlignment="Center"
LostFocus="OnLostFocus"
/>
<TextBlock
Text="{Binding Path=HintText,
RelativeSource={RelativeSource AncestorType=local:InputBar}}"
IsHitTestVisible="False"
Visibility="{Binding ElementName=TextBox, Path=Text, Converter={StaticResource NullToVisibilityConverter}}"
Grid.Column="0"
Padding="5, 0"
VerticalAlignment="Center"
/>
<Button
Click="OnToggleDropDownButtonClick"
Grid.Column="1"
Background="Transparent"
>
<Path
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
Data="M 0 2 L 1 0 L 6 4 L 11 0 L 12 2 L 6 7 Z"
/>
</Button>
</Grid>
<Popup
x:Name="DropDown"
StaysOpen="False"
MaxHeight="400"
Width="{Binding ElementName=TextBox, Path=ActualWidth}"
ScrollViewer.VerticalScrollBarVisibility="Auto"
>
<ListBox
x:Name="ListBox"
ItemContainerStyle="{StaticResource ResourceKey=BlankListBoxContainerStyle}"
ItemsSource="{Binding Path=Collection,
RelativeSource={RelativeSource AncestorType=local:InputBar}}"
SelectionMode="Single"
SelectedItem="{Binding Path=SelectedItem,
RelativeSource={RelativeSource AncestorType=local:InputBar}}"
SelectedIndex="{Binding Path=SelectedIndex,
RelativeSource={RelativeSource AncestorType=local:InputBar}}"
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.VirtualizationMode="Recycling"
>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Text}"></TextBlock>
<StackPanel
Orientation="Horizontal"
>
<StackPanel.Resources>
<Style TargetType="TextBlock">
<Setter Property="Foreground" Value="Gray" />
</Style>
</StackPanel.Resources>
<TextBlock Text="{Binding Type}"></TextBlock>
<TextBlock Text="{Binding Details}" Margin="10,0,0,0"></TextBlock>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Popup>
</Grid>
</UserControl>