Student handleiding added

This commit is contained in:
Mark Kors
2025-12-15 11:10:12 +01:00
parent ce63f9bff9
commit e8c5322782
5 changed files with 1685 additions and 20 deletions

View File

@@ -21,6 +21,7 @@
Margin="10"
VerticalAlignment="Top"
ItemsSource="{Binding Products}"
SelectedItem="{Binding SelectedProduct, Mode=TwoWay}"
DisplayMemberPath="ProductName" />
<Button x:Name="btnAddProduct"
Content="Add Product"
@@ -34,12 +35,12 @@
<TextBox x:Name="txtProductName"
Width="200"
Height="30"
Text="{Binding productName}"
Text="{Binding SelectedProduct.ProductName, UpdateSourceTrigger=PropertyChanged}"
/>
<TextBox x:Name="txtProductPrice"
Width="200"
Height="30"
Text="{Binding productPrice}" />
Text="{Binding SelectedProduct.ProductPrice, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</Grid>
</Window>

View File

@@ -35,10 +35,11 @@ namespace MVVM_DEMO
// display selected product details
if (comboBox.SelectedItem != null && DataContext is MainViewModel viewModel)
{
viewModel.productName = ((Product)comboBox.SelectedItem).ProductName;
viewModel.productPrice = (int)((Product)comboBox.SelectedItem).Price;
viewModel.OnPropertyChanged("productName");
viewModel.OnPropertyChanged("productPrice");
/*viewModel.productName = ((Product)comboBox.SelectedItem).ProductName;
viewModel.productPrice = (int)((Product)comboBox.SelectedItem).ProductPrice;
viewModel.OnPropertyChanged(nameof(viewModel.productName));
viewModel.OnPropertyChanged(nameof(viewModel.productPrice));*/
}
}