<Grid x:Class="GameRes.Formats.GUI.CreateRPAWidget"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:s="clr-namespace:GameRes.Formats.Strings"
      xmlns:p="clr-namespace:GameRes.Formats.Properties"
      xmlns:local="clr-namespace:GameRes.Formats.GUI">
    <Grid.Resources>
        <local:UInt32Converter x:Key="keyConverter"/>
    </Grid.Resources>
    <Grid.ColumnDefinitions>
        <ColumnDefinition/>
        <ColumnDefinition MinWidth="75"/>
    </Grid.ColumnDefinitions>
    <Label Content="{x:Static s:arcStrings.RPALabelKey}" Target="{Binding ElementName=Key}"
           Grid.Column="0" Grid.Row="0" ToolTip="{x:Static s:arcStrings.TooltipHex}" HorizontalAlignment="Right"/>
    <TextBox Name="Key" Grid.Column="1" Grid.Row="0" ToolTip="{x:Static s:arcStrings.TooltipHex}" Margin="3" Width="75">
        <TextBox.Text>
            <Binding Path="RPAKey" Source="{x:Static p:Settings.Default}" Converter="{StaticResource keyConverter}" UpdateSourceTrigger="PropertyChanged">
                <Binding.ValidationRules>
                    <local:PasskeyRule/>
                </Binding.ValidationRules>
            </Binding>
        </TextBox.Text>
        <Validation.ErrorTemplate>
            <ControlTemplate>
                <DockPanel>
                    <TextBlock DockPanel.Dock="Right" Foreground="Red" FontWeight="Bold" Text="!" VerticalAlignment="Center"/>
                    <Border BorderBrush="Red" BorderThickness="1">
                        <AdornedElementPlaceholder Name="ValidationAdorner" />
                    </Border>
                </DockPanel>
            </ControlTemplate>
        </Validation.ErrorTemplate>
    </TextBox>
</Grid>
