ValidationError.ErrorContent 屬性

定義

取得或設定一個物件,提供額外的上下文, ValidationError例如描述錯誤的字串。

public:
 property System::Object ^ ErrorContent { System::Object ^ get(); void set(System::Object ^ value); };
public object ErrorContent { get; set; }
member this.ErrorContent : obj with get, set
Public Property ErrorContent As Object

屬性值

一個提供額外上下文的 ValidationError物件。

範例

以下範例展示了一個樣式觸發器,該觸發器會產生 ToolTip 一個並報告驗證錯誤訊息。 附加屬性 Validation.Errors 會回傳綁定元素上的一組 ValidationError 物件。

<Style x:Key="textStyleTextBox" TargetType="TextBox">
  <Setter Property="Foreground" Value="#333333" />
  <Setter Property="MaxLength" Value="40" />
  <Setter Property="Width" Value="392" />
  <Style.Triggers>
    <Trigger Property="Validation.HasError" Value="true">
      <Setter Property="ToolTip"
        Value="{Binding RelativeSource={RelativeSource Self},
                        Path=(Validation.Errors)[0].ErrorContent}"/>
    </Trigger>
  </Style.Triggers>
</Style>

備註

XAML 文字使用

請參見範例章節。

適用於