Guest User

Untitled

a guest
Apr 25th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. <ScrollViewer>
  2. <StackPanel x:Name="ShopList"/>
  3. </ScrollViewer>
  4.  
  5. <Button
  6. x:Name="FoodAdd"
  7. Content="Добавить"
  8. Margin="287,102,0,17"
  9. Height="81"
  10. Width="130"
  11. BorderBrush="#FFFBEFEF"
  12. Foreground="#FFFFF7F7"
  13. Background="#FF56E0C7"
  14. FontFamily="/Assets/Fonts/Stolzl.otf#Stolzl Light"
  15. Click="NewItem"/>
  16.  
  17. private void NewItem(object sender, RoutedEventArgs e)
  18. {
  19. string item_name = NewFood.Text;
  20. if(item_name.Trim(' ') != "")
  21. {
  22. Button new_button = new Button();
  23. new_button.Content = item_name;
  24. new_button.Width = 350;
  25. new_button.HorizontalContentAlignment = HorizontalAlignment.Left;
  26. new_button.FontSize = 30;
  27. Thickness thick = new Thickness(0);
  28. thick.Bottom = 1;
  29. new_button.BorderThickness = thick;
  30. new_button.BorderBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0x4F, 0x4E, 0x4E));
  31. new_button.Click += Delete_fromlist;
  32.  
  33. ShopList.Children.Add(new_button);
  34. }
  35. NewFood.Text = "";
  36. NewFood.Focus(FocusState.Keyboard);
  37. }
  38.  
  39. private void Delete_fromlist(object sender, RoutedEventArgs e)
  40. {
  41. ((Button)sender).Content = "";
  42. ShopList.Children.Remove(((Button)sender));
  43. }
Add Comment
Please, Sign In to add comment