Student handleiding added
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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));*/
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user