Wpf DataGridTextColumn上的拼写检查器
你好。我还是一名初级程序员,最近开始使用WPF编写代码。我有一个datagrid,我在其中生成自己的列。在一个特定的列DataGridTextColumn中,我必须应用拼写检查(用户可以向该字段添加注释)。但我没办法做到这一点。我尝试过运用一种风格,但没有成功。任何帮助都将不胜感激!以下是该列的编码:Wpf DataGridTextColumn上的拼写检查器,wpf,xaml,spell-checking,Wpf,Xaml,Spell Checking,你好。我还是一名初级程序员,最近开始使用WPF编写代码。我有一个datagrid,我在其中生成自己的列。在一个特定的列DataGridTextColumn中,我必须应用拼写检查(用户可以向该字段添加注释)。但我没办法做到这一点。我尝试过运用一种风格,但没有成功。任何帮助都将不胜感激!以下是该列的编码: <DataGridTextColumn x:Name="clValueComment" Binding="{Binding CommentColumn, Mode=TwoWay, U
<DataGridTextColumn x:Name="clValueComment" Binding="{Binding CommentColumn, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Header="ROOTCAUSE OR COMMENT" Width="*" IsReadOnly="False" Style="{StaticResource Spell}">
<DataGridTextColumn.CellStyle>
<Style TargetType="{x:Type DataGridCell}">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Foreground" Value="Black" />
</Trigger>
<DataTrigger Binding="{Binding valueTypeID}" Value="1">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<Label IsEnabled="False"/>
</DataTemplate>
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</DataGridTextColumn.CellStyle>
</DataGridTextColumn>
在尝试了更多的样式选项后,我找到了一个似乎有效的解决方案。我会把它贴出来,作为可能遇到同样要求的人的答案。实现这一技巧的XAML编码是:
<DataGridTextColumn.EditingElementStyle>
<Style TargetType="TextBox">
<Setter Property="SpellCheck.IsEnabled" Value="True"/>
</Style>
</DataGridTextColumn.EditingElementStyle>
谢谢,帮了我的忙!对于遇到此问题的任何其他人,它仅在编辑文本时有效(如上所述),在常规视图模式下不会显示错误。