0

TextBoxクラスプロパティに接続されている があります。

<TextBox Name="txtbSleeveLength"   
         Grid.Row="0" 
         Grid.Column="1" 
         VerticalAlignment="Center" 
         HorizontalAlignment="Center" 
         Height="23" Margin="1" 
         Text="{Binding Path=SleeveLength, StringFormat=N2}" 
         Width="120" 
         TextAlignment ="Center" 
         GotFocus="txtbSleeveLength_GotFocus" />

クラスからのプロパティ

public class SleevePattern : Shape, INotifyPropertyChanged
{
 //...
    public event PropertyChangedEventHandler PropertyChanged;
    //...
    protected void Notify(string propertyName)
    {
        if (this.PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }
    //...
  public double SleeveLength
    {

        get { return sleeveLength; }
        set
        {
            if (value != sleeveLength)
            {
                sleeveLength = value;
                Notify("SleeveLength");
            }

        }
    }
    //...    

}

プロパティは null 許容ではないため、2 つの効果が発生します。最初に「0.00」があり、満たされていないTextBox場合はTextBox、テキスト ボックスの周りに赤い四角形が表示されます。

ここTextBoxで、この四角形を担当するプロパティは 何ですか(存在する場合)? があると聞きましたErrorProvider。XAML タグで使用して例外を取得し、四角形を感嘆符付きの赤い円に変更できますか?

4

1 に答える 1