- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 IDataErrorInfo 来验证和指示我的文本框中的错误。我发现我必须为文本框按一次 Tab 键,为装饰装饰器按一次 Tab 键。
我有一个错误模板:
<ControlTemplate x:Key="ErrorTemplate">
<StackPanel KeyboardNavigation.IsTabStop="False" >
<Border KeyboardNavigation.IsTabStop="False" BorderBrush="Red" BorderThickness="1" Padding="2" CornerRadius="2">
<AdornedElementPlaceholder KeyboardNavigation.IsTabStop="False" />
</Border>
</StackPanel>
</ControlTemplate>
一个文本框模板:
<Style x:Key="TextBoxInError" TargetType="{x:Type TextBox}">
<Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Margin" Value="0,5,0,5"/>
<Setter Property="AllowDrop" Value="true"/>
<Setter Property="HorizontalContentAlignment" Value="left"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<Grid KeyboardNavigation.IsTabStop="False" >
<Border KeyboardNavigation.IsTabStop="False" x:Name="Border" Background="{DynamicResource WindowBackgroundBrush}" BorderBrush="{DynamicResource SolidBorderBrush}" BorderThickness="1" Padding="2" CornerRadius="2">
<ScrollViewer IsTabStop="False" Margin="0" x:Name="PART_ContentHost" Style="{DynamicResource SimpleScrollViewer}" Background="{TemplateBinding Background}"/>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors), Converter={StaticResource errorConverter}}"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="Gray"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
并像这样声明一个文本框:
<AdornerDecorator KeyboardNavigation.IsTabStop="False" >
<TextBox Margin="5,5,5,3" x:Name="txtName" IsEnabled="{Binding EditMode}" Validation.ErrorTemplate="{StaticResource ErrorTemplate}"
Text="{Binding ApplicationName, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}"
Height="25" MaxLength="50" MaxLines="1" Style="{StaticResource TextBoxInError}"/>
</AdornerDecorator>
如果装饰器像上面那样环绕一个文本框,那么我按一次 Tab 键离开文本框,然后按一次 Tab 键离开“装饰”(看起来)对于文本框,则必须依次返回所有“装饰”。在装饰物中切换时,焦点会转到控件模板中定义的红色边框上。
有什么想法吗?
谢谢
最佳答案
将其添加到窗口的资源部分:
<Style TargetType="{x:Type Control}">
<Setter Property="Focusable" Value="False"/>
</Style>
有关更多信息,请查看我的博客:http://www.nbdtech.com/blog/archive/2008/05/25/WPF-Problems-with-Keyboard-Focus-When-Using-Validation.aspx
关于wpf - AdornerDecorator 和制表位问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/354717/
如何使用 tabulate 包在 python 中合并多个表? append 在 python 中连接两个表时不起作用。这些表是使用 python 中的 tabulate 包实现的。 table_1
我想使用制表法将两个表格并排显示。 我的方法: test_table1 = tabulate([['Alice', 24], ['Bob', 19]]) test_table2 = tabulate(
我之前在大学学习过 Java 的为期 3 个月的短期类(class)(唯一的项目是编写数独游戏)。 我想学习一种对于一般自动化任务来说最流行的编程语言。到目前为止,我已经选择了 AHK,它帮助我完成了
我的脚本有问题.. 用户需要向一个 div 输入数据,当一个 div 已满(4 个字符)时,脚本应自动移动到下一个字段。 在处理输入时,这非常有效: http://jsfiddle.net/4m5fg
我正在使用 MySQL Workbench 来编写一些查询。我想设置 MySQL 编辑器,以便在按 Enter 键换行时在下一行中保持对齐或水平制表。就像编程编辑通常所做的那样,我想你就是我的意思。
我正在尝试:(1) 估计只有因变量发生变化的多个模型 (2) 使用 Stargazer 包将结果制表 以下代码有效,但我必须为每个模型重复一行代码: library(stargazer)
我是一名优秀的程序员,十分优秀!