Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. ...
  2. row = query.DefaultView[0];
  3. DataContext = row;
  4.  
  5. <TextBox Text="{Binding Path=Price, Mode=TwoWay}"/>
  6.  
  7. public class IntToStringConverter : IValueConverter
  8. {
  9.  
  10. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  11. {
  12. int price = (int)value;
  13. return price.ToString();
  14. }
  15.  
  16. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  17. {
  18. string text = (string)value;
  19. int price;
  20. if (!int.TryParse(text, out price))
  21. {
  22. MessageBox.Show("Enter valid value for Price!");
  23. return 0; //Some default value
  24. }
  25.  
  26. return price;
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement