code_junkie

AdornerDecorator and tab stop issues

Nov 12th, 2011
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. <ControlTemplate x:Key="ErrorTemplate">
  2. <StackPanel KeyboardNavigation.IsTabStop="False" >
  3. <Border KeyboardNavigation.IsTabStop="False" BorderBrush="Red" BorderThickness="1" Padding="2" CornerRadius="2">
  4. <AdornedElementPlaceholder KeyboardNavigation.IsTabStop="False" />
  5. </Border>
  6. </StackPanel>
  7. </ControlTemplate>
  8.  
  9. <Style x:Key="TextBoxInError" TargetType="{x:Type TextBox}">
  10. <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
  11. <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
  12. <Setter Property="Margin" Value="0,5,0,5"/>
  13. <Setter Property="AllowDrop" Value="true"/>
  14. <Setter Property="HorizontalContentAlignment" Value="left"/>
  15. <Setter Property="Template">
  16. <Setter.Value>
  17. <ControlTemplate TargetType="{x:Type TextBox}">
  18. <Grid KeyboardNavigation.IsTabStop="False" >
  19. <Border KeyboardNavigation.IsTabStop="False" x:Name="Border" Background="{DynamicResource WindowBackgroundBrush}" BorderBrush="{DynamicResource SolidBorderBrush}" BorderThickness="1" Padding="2" CornerRadius="2">
  20. <ScrollViewer IsTabStop="False" Margin="0" x:Name="PART_ContentHost" Style="{DynamicResource SimpleScrollViewer}" Background="{TemplateBinding Background}"/>
  21. </Border>
  22. </Grid>
  23. <ControlTemplate.Triggers>
  24. <Trigger Property="Validation.HasError" Value="true">
  25. <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors), Converter={StaticResource errorConverter}}"/>
  26. </Trigger>
  27. <Trigger Property="IsEnabled" Value="false">
  28. <Setter Property="Foreground" Value="Gray"/>
  29. </Trigger>
  30. </ControlTemplate.Triggers>
  31. </ControlTemplate>
  32. </Setter.Value>
  33. </Setter>
  34. </Style>
  35.  
  36. <AdornerDecorator KeyboardNavigation.IsTabStop="False" >
  37. <TextBox Margin="5,5,5,3" x:Name="txtName" IsEnabled="{Binding EditMode}" Validation.ErrorTemplate="{StaticResource ErrorTemplate}"
  38. Text="{Binding ApplicationName, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}"
  39. Height="25" MaxLength="50" MaxLines="1" Style="{StaticResource TextBoxInError}"/>
  40. </AdornerDecorator>
  41.  
  42. <Style TargetType="{x:Type Control}">
  43. <Setter Property="Focusable" Value="False"/>
  44. </Style>
Add Comment
Please, Sign In to add comment