Advertisement
BionicCode

Generic.xaml

May 5th, 2024 (edited)
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 2.85 KB | Source Code | 0 0
  1.  <Style TargetType="local:NumericTextBox">
  2.    <Style.Resources>
  3.      <ControlTemplate x:Key="ValidationErrorTemplate1">
  4.        <StackPanel>
  5.          <Border BorderBrush="Red"
  6.                 BorderThickness="1"
  7.                 HorizontalAlignment="Left">
  8.  
  9.            <!-- Placeholder for the NumericTextBox itself -->
  10.            <AdornedElementPlaceholder x:Name="AdornedElement" />
  11.          </Border>
  12.  
  13.          <Border Background="White"
  14.                 BorderBrush="Red"
  15.                 Padding="4"
  16.                 BorderThickness="1"
  17.                 HorizontalAlignment="Left">
  18.            <ItemsControl ItemsSource="{Binding}"
  19.                         HorizontalAlignment="Left">
  20.              <ItemsControl.ItemTemplate>
  21.                <DataTemplate>
  22.                  <TextBlock Text="{Binding ErrorContent}"
  23.                            Foreground="Red" />
  24.                </DataTemplate>
  25.              </ItemsControl.ItemTemplate>
  26.            </ItemsControl>
  27.          </Border>
  28.        </StackPanel>
  29.      </ControlTemplate>
  30.    </Style.Resources>
  31.    <Setter Property="Background"
  32.           Value="{x:Static SystemColors.ControlLightBrush}" />
  33.    <Setter Property="BorderBrush"
  34.           Value="{x:Static SystemColors.ActiveBorderBrush}" />
  35.    <Setter Property="BorderThickness"
  36.           Value="1" />
  37.    <Setter Property="Validation.ErrorTemplate"
  38.           Value="{StaticResource ValidationErrorTemplate1}" />
  39.    <Setter Property="Template">
  40.      <Setter.Value>
  41.        <ControlTemplate TargetType="local:NumericTextBox">
  42.          <Border Background="{TemplateBinding Background}"
  43.                 BorderBrush="{TemplateBinding BorderBrush}"
  44.                 BorderThickness="{TemplateBinding BorderThickness}"
  45.                 Padding="{TemplateBinding Padding}">
  46.            <VisualStateManager.VisualStateGroups>
  47.              <VisualStateGroup x:Name="CommonStates">
  48.                <VisualState x:Name="Normal" />
  49.                <VisualState x:Name="Disabled">
  50.                  <Storyboard>
  51.                    <ColorAnimationUsingKeyFrames Storyboard.TargetName="Border"
  52.                                                 Storyboard.TargetProperty="(Panel.Background).
  53.                   (SolidColorBrush.Color)">
  54.                      <EasingColorKeyFrame KeyTime="0"
  55.                                          Value="{x:Static SystemColors.InactiveBorderColor}" />
  56.                    </ColorAnimationUsingKeyFrames>
  57.                  </Storyboard>
  58.                </VisualState>
  59.                <VisualState x:Name="ReadOnly" />
  60.                <VisualState x:Name="MouseOver" />
  61.              </VisualStateGroup>
  62.            </VisualStateManager.VisualStateGroups>
  63.  
  64.            <ScrollViewer Margin="0"
  65.                         x:Name="PART_ContentHost" />
  66.          </Border>
  67.        </ControlTemplate>
  68.      </Setter.Value>
  69.    </Setter>
  70.  </Style>
Tags: wpf xaml
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement