Guest User

Untitled

a guest
Jan 19th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. if (!int.TryParse(value.ToString(), out proposedValue))
  2. {
  3. return new ValidationResult(false, "'" + value.ToString() + "' ist no positive integer (>=0).");
  4. }
  5.  
  6. if (proposedValue < 0)
  7. {
  8. // Something was wrong.
  9. return new ValidationResult(false, "Value can't be smaller than 0.");
  10. }
  11. }
  12.  
  13. // Everything OK.
  14. return new ValidationResult(true, null);
  15. }
  16. }
  17.  
  18. <DataGridTextColumn Header="Shitfs" IsReadOnly="False">
  19. <DataGridTextColumn.Binding>
  20. <Binding Path="Shifts">
  21. <Binding.ValidationRules>
  22. <validationRules:IsPositiveIntegerRule />
  23. </Binding.ValidationRules>
  24. </Binding>
  25. </DataGridTextColumn.Binding>
  26. </DataGridTextColumn>
  27.  
  28. <Style TargetType="TextBlock">
  29. <Style.Triggers>
  30. <Trigger Property="Validation.HasError" Value="true">
  31. <Setter Property="ToolTip"
  32. Value="{Binding RelativeSource={x:Static RelativeSource.Self},
  33. Path=(Validation.Errors)[0].ErrorContent}"/>
  34. </Trigger>
  35. </Style.Triggers>
  36. </Style>
  37.  
  38. <Style x:Key="CellEditStyle" TargetType="TextBox">
  39. <Style.Triggers>
  40. <Trigger Property="Validation.HasError" Value="true">
  41. <Setter Property="ToolTip"
  42. Value="{Binding RelativeSource={RelativeSource Self},
  43. Path=(Validation.Errors)[0].ErrorContent}"/>
  44. </Trigger>
  45. </Style.Triggers>
  46. </Style>
  47.  
  48. <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}"/>
Add Comment
Please, Sign In to add comment