public void SetProduct(ProductDetailViewModel model) { ProductStack.Children.Clear(); foreach (PropertyInfo info in model.GetType().GetProperties()) { FieldLabel label = info.GetCustomAttribute<FieldLabel>(); Label lbl = new Label(); if (label != null) { lbl.Content = String.Format("{0} : {1}", label.Label, info.GetValue(model).ToString()); ProductStack.Children.Add(lbl); } } this.Visibility = Visibility.Visible; }
private void ProductsGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e) { DataGrid grid = (DataGrid)sender; ProductGridViewModel p = (ProductGridViewModel)grid.SelectedItem; if (p != null) { Product product = Products.Single<Product>(w => w.ShopProductCode == p.ShopProductCode); ProductDetailViewModel m = new ProductDetailViewModel(product); ProductDetailCtrl.SetProduct(m); this.ProductsGrid.Visibility = Visibility.Hidden; this.ProductDetailCtrl.Visibility = Visibility.Visible; } }