Showing Validation.Errors in tooltip not working
-
13-07-2021 - |
Question
I'm trying to show the Validation.error message inside a tooltip in my DataGrid cell but without success. Here is the code of the concerned column. Please tell me if i'm doing something wrong. I did get the idea of the converter from this tutorial
<DataGridTemplateColumn Width="200" Header="Numéro Chassis" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding NumeroChassis}">
</TextBlock>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<TextBox ToolTip="{Binding Path=(Validation.Errors),
Converter={StaticResource eToMConverter}}">
<TextBox.Text>
<Binding Path="NumeroChassis" >
<Binding.ValidationRules>
<inf:NoNullValidationRule/>
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>
Solution
I did work with RelativeSource and it worked pretty well, just replacing :
<TextBox ToolTip="{Binding Path=(Validation.Errors),
Converter={StaticResource eToMConverter}}">
with :
<TextBox ToolTip="{Binding Path=(Validation.Errors), RelativeSource={RelativeSource Self},Converter={StaticResource eToMConverter}}">
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow