Guest User

Untitled

a guest
Nov 20th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. public class Product : Window
  2. {
  3. public string Name { get; set; }
  4. public int Number { get; set; }
  5. public int Price { get; set; }
  6. public int Sum => Number* Price;
  7.  
  8. public static Product[] GetProducts()
  9. {
  10. var result = new Product[]
  11. {
  12. new Product { Name = "Photoshop", Number = 1, Price = 20 },
  13. new Product { Name = "Illustrator", Number = 1, Price = 10 },
  14. new Product { Name = "Dreamviewer", Number = 1, Price = 50 },
  15. new Product { Name = "Audition", Number = 1, Price = 15 },
  16. new Product { Name = "Bridge", Number = 1, Price = 15 },
  17. new Product { Name = "Flash", Number = 1, Price = 15 },
  18. new Product { Name = "Lightroom", Number = 1, Price = 15 }
  19. };
  20. return result;
  21. }
  22. }
  23.  
  24. <ListView ItemsSource="{DynamicResource ResourceKey=Product}"
  25. VerticalAlignment="Top" HorizontalAlignment="Left"
  26. Name="ListV" Height="310" Width="360">
  27. <ListView.View>
  28. <GridView>
  29. <GridViewColumn DisplayMemberBinding="{Binding Path=Name}" Header="Наименование" Width="120" />
  30. <GridViewColumn DisplayMemberBinding="{Binding Path=Number}" Header="Цена" Width="50" />
  31. <GridViewColumn DisplayMemberBinding="{Binding Path=Price}" Header="Количество" Width="100" />
  32. <GridViewColumn DisplayMemberBinding="{Binding Path=Sum}" Header="Итого" Width="80" />
  33. </GridView>
  34. </ListView.View>
  35. <ListView.Resources>
  36. <col:ArrayList x:Key="Product">
  37. </col:ArrayList>
  38. </ListView.Resources>
  39.  
  40. public partial class MainWindow : Window
  41. {
  42. public MainWindow()
  43. {
  44. InitializeComponent();
  45.  
  46. ListV.ItemsSource = Product.GetProducts();
  47. }
  48. }
  49.  
  50. class BaseVM : DependencyObject
  51. {
  52. public int X
  53. {
  54. get { return (int)GetValue(XProperty); }
  55. set { SetValue(XProperty, value); }
  56. }
  57.  
  58. public static readonly DependencyProperty XProperty = DependencyProperty.Register(
  59. "X", typeof(int), typeof(BaseVM), new PropertyMetadata(13));
  60. }
  61.  
  62. class DerivedVM : BaseVM
  63. {
  64. public int X { get; } = 44;
  65. }
  66.  
  67. <Grid TextBlock.FontSize="24">
  68. <TextBlock Text="{Binding X}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
  69. </Grid>
Add Comment
Please, Sign In to add comment