Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Product : Window
- {
- public string Name { get; set; }
- public int Number { get; set; }
- public int Price { get; set; }
- public int Sum => Number* Price;
- public static Product[] GetProducts()
- {
- var result = new Product[]
- {
- new Product { Name = "Photoshop", Number = 1, Price = 20 },
- new Product { Name = "Illustrator", Number = 1, Price = 10 },
- new Product { Name = "Dreamviewer", Number = 1, Price = 50 },
- new Product { Name = "Audition", Number = 1, Price = 15 },
- new Product { Name = "Bridge", Number = 1, Price = 15 },
- new Product { Name = "Flash", Number = 1, Price = 15 },
- new Product { Name = "Lightroom", Number = 1, Price = 15 }
- };
- return result;
- }
- }
- <ListView ItemsSource="{DynamicResource ResourceKey=Product}"
- VerticalAlignment="Top" HorizontalAlignment="Left"
- Name="ListV" Height="310" Width="360">
- <ListView.View>
- <GridView>
- <GridViewColumn DisplayMemberBinding="{Binding Path=Name}" Header="Наименование" Width="120" />
- <GridViewColumn DisplayMemberBinding="{Binding Path=Number}" Header="Цена" Width="50" />
- <GridViewColumn DisplayMemberBinding="{Binding Path=Price}" Header="Количество" Width="100" />
- <GridViewColumn DisplayMemberBinding="{Binding Path=Sum}" Header="Итого" Width="80" />
- </GridView>
- </ListView.View>
- <ListView.Resources>
- <col:ArrayList x:Key="Product">
- </col:ArrayList>
- </ListView.Resources>
- public partial class MainWindow : Window
- {
- public MainWindow()
- {
- InitializeComponent();
- ListV.ItemsSource = Product.GetProducts();
- }
- }
- class BaseVM : DependencyObject
- {
- public int X
- {
- get { return (int)GetValue(XProperty); }
- set { SetValue(XProperty, value); }
- }
- public static readonly DependencyProperty XProperty = DependencyProperty.Register(
- "X", typeof(int), typeof(BaseVM), new PropertyMetadata(13));
- }
- class DerivedVM : BaseVM
- {
- public int X { get; } = 44;
- }
- <Grid TextBlock.FontSize="24">
- <TextBlock Text="{Binding X}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
- </Grid>
Add Comment
Please, Sign In to add comment