Share via


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

屬性值

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 文字使用方式

如需範例,請參閱一節。

適用於