簡體   English   中英

擴展的WPF工具包-使用FormatBar樣式化RichTextBox會導致異常

[英]Extended WPF Toolkit - Styling the RichTextBox with FormatBar causes exception

我正在嘗試像這樣擴展WPF工具包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:“值不能為null。參數名稱:property”。

是什么導致這種行為?

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

不幸的是,它給了我同樣的例外。

值期望實例不是類型。 請試試

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM