フォームにコンボボックスとボタンがあります。コンボボックスにはカテゴリがあります。ブール値に基づいて 'システムカテゴリ'である場合は、保留中のものを許可/禁止します。WPF/C#IDataErrorInfo Not Firing
<StackPanel Grid.Column="1" Grid.Row="1">
<Label Content="Delete Category" Height="28"/>
<ComboBox x:Name="comboBox_DeleteCategory"
Grid.Row="1"
Height="29"
ItemsSource="{Binding Path=CategorySelected.Items, ValidatesOnDataErrors=true, NotifyOnValidationError=true}"
SelectedItem="{Binding Path=CategorySelected.SelectedItem ,ValidatesOnDataErrors=True, NotifyOnValidationError=true}"
DisplayMemberPath="Name"/>
<Button Content="Delete" Height="25" Margin="0,5,0,0" HorizontalAlignment="Right" Width="103.307" Command="{Binding DeleteCommand}"/>
</StackPanel>
と判断された場合、私は、ツールチップを表示するコンボボックスを取得しようとしています:これは、その中の2つのコントロールを持つスタックパネルがある
<Window.Resources>
<Style TargetType="{x:Type ComboBox}">
<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>
</Window.Resources>
:ここ
は私のXAMLですこれはシステムカテゴリであることを示します。DeleteCommandは正常に動作しているため、システムカテゴリでヒットしたときにボタンが無効になる問題は発生しません。
これは、ツールチップを表示するために私のコードです:
#region IDataErrorInfo Members
public string Error { get; set; }
public string this[string columnName]
{
get
{
Error = "";
switch (columnName)
{
case "comboBox_DeleteCategory":
if (CategorySelected.SelectedItem != null && CategorySelected.SelectedItem.IsInternal)
{
Error = CategorySelected.SelectedItem.Name + " is an system category and cannot be deleted.";
break;
}
break;
}
return Error;
}
}
#endregion
任意の提案ですか?
おかげで、
Eroc