Hi all,
I'm developing with MVVM and try to show an error for a DataGridcomboBoxColumn as tooltip:
<DataGridComboBoxColumn Header="Waregroup" Width="250"><DataGridComboBoxColumn.ElementStyle><Style TargetType="ComboBox" ><Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.waregroups}"/><Setter Property="DisplayMemberPath" Value="name" /><Setter Property="SelectedValuePath" Value="waregroupID" /><Setter Property="SelectedItem" Value="{Binding waregroup, ValidatesOnDataErrors=True, NotifyOnValidationError=True}" /><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></DataGridComboBoxColumn.ElementStyle><DataGridComboBoxColumn.EditingElementStyle><Style TargetType="ComboBox"><Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.waregroups}"/><Setter Property="DisplayMemberPath" Value="name" /><Setter Property="SelectedValuePath" Value="waregroupID" /><Setter Property="SelectedItem" Value="{Binding waregroup}" /></Style></DataGridComboBoxColumn.EditingElementStyle></DataGridComboBoxColumn>The style the box references to is:
<Style x:Key="errorStyle_ComboBox" TargetType="{x:Type ComboBox}"><Style.Triggers><Trigger Property="Validation.HasError" Value="True"><Setter Property="ToolTip"
Value="{Binding RelativeSource={RelativeSource Self},
Path=(Validation.Errors).CurrentItem.ErrorContent}"/></Trigger></Style.Triggers></Style>The validity check is done in the model by implementing IDataErrorInfo and for Textboxcolumns with a similar template this works fine. (If the validation fails the tooltip is shown)
Setting a breakpoint in the model for the according validation of the waregroup (is a waregroup selected) also does work - but no error or tooltip is shown in the view.
I'd be grateful for any hints on that topic.