2012-07-01 36 views
0

我想樣式擴展WPF工具包RichTextBox的,像這樣:擴展WPF工具包 - 與FormatBar樣式化的RichTextBox導致異常

<Style TargetType="{x:Type tk:RichTextBox}"> 
    <Setter Property="VerticalScrollBarVisibility" Value="Auto"/> 
    <Setter Property="SpellCheck.IsEnabled" Value="True"/> 
    <Setter Property="tk:RichTextBoxFormatBarManager.FormatBar" Value="{x:Type tk:RichTextBoxFormatBar}"/> 
</Style> 

然而,在運行時,它失敗,出現ArgumentNullException說:「值不能爲空。參數名稱:屬性「。

什麼可能導致此行爲?

編輯1 我也試過這個語法:

<Style TargetType="{x:Type tk:RichTextBox}"> 
    <Setter Property="VerticalScrollBarVisibility" Value="Auto"/> 
    <Setter Property="SpellCheck.IsEnabled" Value="True"/> 
    <Setter Property="tk:RichTextBoxFormatBarManager.FormatBar"> 
     <Setter.Value> 
      <tk:RichTextBoxFormatBar /> 
     </Setter.Value> 
    </Setter> 
</Style> 

不幸的是它給了我同樣的異常。

回答

1

值期望實例不是Type。請嘗試

<Style TargetType="{x:Type tk:RichTextBox}"> 
    <Setter Property="VerticalScrollBarVisibility" Value="Auto" /> 
    <Setter Property="SpellCheck.IsEnabled" Value="True" /> 
    <Setter Property="tk:RichTextBoxFormatBarManager.FormatBar"> 
     <Setter.Value> 
      <tk:RichTextBoxFormatBar /> 
     </Setter.Value> 
    </Setter> 
</Style> 
+0

感謝您的輸入。不幸的是問題依然存在 – Farawin

相關問題