Files
Ursa.Avalonia/src/Ursa.Themes.Semi/Controls/PinCode.axaml

88 lines
4.7 KiB
XML

<ResourceDictionary
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:u="https://irihi.tech/ursa">
<Design.PreviewWith>
<u:PinCode Count="4" />
</Design.PreviewWith>
<ControlTheme x:Key="{x:Type u:PinCodeItem}" TargetType="u:PinCodeItem">
<Setter Property="Focusable" Value="True" />
<Setter Property="Height" Value="{DynamicResource TextBoxDefaultHeight}" />
<Setter Property="Width" Value="{DynamicResource TextBoxDefaultHeight}" />
<Setter Property="CornerRadius" Value="{DynamicResource TextBoxDefaultCornerRadius}" />
<Setter Property="BorderThickness" Value="{DynamicResource TextBoxBorderThickness}" />
<Setter Property="Background" Value="{DynamicResource TextBoxDefaultBackground}" />
<Setter Property="FocusAdorner" Value="{x:Null}" />
<Setter Property="Template">
<ControlTemplate>
<Border
Name="PART_Background"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Background="{TemplateBinding Background}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}">
<TextPresenter
HorizontalAlignment="Center"
VerticalAlignment="Center"
PasswordChar="{TemplateBinding PasswordChar}"
Text="{TemplateBinding Text}"
TextElement.FontSize="{TemplateBinding FontSize}" />
</Border>
</ControlTemplate>
</Setter>
<Style Selector="^:pointerover /template/ Border#PART_Background">
<Setter Property="Background" Value="{DynamicResource TextBoxPointeroverBackground}" />
</Style>
<Style Selector="^:focus /template/ Border#PART_Background">
<Setter Property="Background" Value="{DynamicResource TextBoxPointeroverBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource TextBoxFocusBorderBrush}" />
</Style>
<Style Selector="^:error /template/ Border#PART_Background">
<Setter Property="Background" Value="{DynamicResource DataValidationErrorsSelectedBackground}" />
</Style>
<Style Selector="^:focus:error /template/ Border#PART_Background">
<Setter Property="BorderBrush" Value="{DynamicResource DataValidationErrorsSelectedBorderBrush}" />
</Style>
<Style Selector="^.Large">
<Setter Property="Height" Value="{DynamicResource TextBoxLargeHeight}" />
<Setter Property="Width" Value="{DynamicResource TextBoxLargeHeight}" />
</Style>
<Style Selector="^.Small">
<Setter Property="Height" Value="{DynamicResource TextBoxSmallHeight}" />
<Setter Property="Width" Value="{DynamicResource TextBoxSmallHeight}" />
</Style>
</ControlTheme>
<ControlTheme x:Key="{x:Type u:PinCodeCollection}" TargetType="u:PinCodeCollection">
<Setter Property="Template">
<ControlTemplate TargetType="u:PinCodeCollection">
<ItemsPresenter ItemsPanel="{TemplateBinding ItemsPanel}" />
</ControlTemplate>
</Setter>
</ControlTheme>
<ControlTheme x:Key="{x:Type u:PinCode}" TargetType="u:PinCode">
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="Template">
<ControlTemplate TargetType="u:PinCode">
<DataValidationErrors>
<u:PinCodeCollection HorizontalAlignment="Left" Name="{x:Static u:PinCode.PART_ItemsControl}" ItemsSource="{TemplateBinding Digits}">
<u:PinCodeCollection.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</u:PinCodeCollection.ItemsPanel>
<u:PinCodeCollection.ItemContainerTheme>
<ControlTheme BasedOn="{StaticResource {x:Type u:PinCodeItem}}" TargetType="u:PinCodeItem">
<Setter Property="PasswordChar" Value="{Binding $parent[u:PinCode].PasswordChar}" />
<Setter Property="DataValidationErrors.Errors" Value="{Binding $parent[u:PinCode].(DataValidationErrors.Errors)}" />
</ControlTheme>
</u:PinCodeCollection.ItemContainerTheme>
</u:PinCodeCollection>
</DataValidationErrors>
</ControlTemplate>
</Setter>
</ControlTheme>
</ResourceDictionary>