2015-11-30 39 views
2

美好的一天。我仍然是一名初級程序員,最近開始在WPF中編寫代碼。我有一個datagrid,我可以生成自己的列。在一個特定的列DataGridTextColumn中,我必須應用拼寫檢查(用戶可以向此字段添加註釋)。但我無法做到這一點。我曾嘗試應用風格,但沒有運氣。任何援助將不勝感激!這裏是列的編碼:DataGridTextColumn上的拼寫檢查器

<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> 

回答

4

玩了一些更多的樣式選項後,我發現一個似乎工作的解決方案。我會將它作爲可能遇到相同要求的人的答案發布。訣竅的XAML編碼是:

<DataGridTextColumn.EditingElementStyle> 
         <Style TargetType="TextBox"> 
          <Setter Property="SpellCheck.IsEnabled" Value="True"/> 
         </Style> 
        </DataGridTextColumn.EditingElementStyle> 
+0

謝謝,幫助我!對於遇到此問題的其他人而言,它只在編輯文本時起作用(如所述),但在常規視圖模式下不會顯示錯誤。 –