116 lines
4.8 KiB
XML
116 lines
4.8 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"
|
|
mc:Ignorable="d"
|
|
x:ClassModifier="internal"
|
|
x:Name="_this"
|
|
d:DesignHeight="100" d:DesignWidth="800"
|
|
>
|
|
<UserControl.Resources>
|
|
<local:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
|
|
<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>
|
|
<TextBox
|
|
x:Name="TextBox"
|
|
Text="{Binding Path=Text,
|
|
RelativeSource={RelativeSource AncestorType=local:InputBar},
|
|
UpdateSourceTrigger=PropertyChanged}"
|
|
PreviewKeyDown="OnPreviewKeyDown"
|
|
Padding="2, 0"
|
|
VerticalContentAlignment="Center"
|
|
TextChanged="OnTextChanged"
|
|
LostFocus="OnLostFocus"
|
|
/>
|
|
<TextBlock
|
|
Text="{Binding Path=HintText,
|
|
RelativeSource={RelativeSource AncestorType=local:InputBar}}"
|
|
IsHitTestVisible="False"
|
|
Visibility="{Binding ElementName=TextBox, Path=Text, Converter={StaticResource NullToVisibilityConverter}}"
|
|
Padding="5, 0"
|
|
VerticalAlignment="Center"
|
|
/>
|
|
</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"
|
|
SelectionChanged="OnSelectionChanged"
|
|
VirtualizingPanel.IsVirtualizing="True"
|
|
VirtualizingPanel.VirtualizationMode="Recycling"
|
|
>
|
|
<ListBox.ItemTemplate>
|
|
<DataTemplate>
|
|
<StackPanel Orientation="Vertical">
|
|
<TextBlock Text="{Binding Text}" FontWeight="Bold"></TextBlock>
|
|
<TextBlock Text="{Binding Type}"></TextBlock>
|
|
</StackPanel>
|
|
</DataTemplate>
|
|
</ListBox.ItemTemplate>
|
|
</ListBox>
|
|
</Popup>
|
|
</Grid>
|
|
</UserControl>
|