Files
mvvm_demo/Views/MainWindow.xaml
Mark Kors ce63f9bff9 Implementeer ICommand patroon met RelayCommand voor MVVM
- Voeg RelayCommand class toe voor herbruikbare ICommand implementatie
- Vervang button click event handler door AddProductCommand in MainViewModel
- Update XAML om Command binding te gebruiken in plaats van Click event
- Verwijder business logic uit code-behind (MainWindow.xaml.cs)
- Los DataContext duplicatie op (was twee keer MainViewModel instantie)

Dit maakt de applicatie beter testbaar en volgt proper MVVM principes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-12 19:11:54 +01:00

46 lines
1.7 KiB
XML

<Window x:Class="MVVM_DEMO.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MVVM_DEMO"
xmlns:vm="clr-namespace:MVVM_DEMO.ViewModels"
mc:Ignorable="d"
Title="MainWindow"
Height="450"
Width="800">
<Window.DataContext>
<vm:MainViewModel />
</Window.DataContext>
<Grid>
<StackPanel>
<ComboBox x:Name="comboBox"
Width="200"
Height="30"
Margin="10"
VerticalAlignment="Top"
ItemsSource="{Binding Products}"
DisplayMemberPath="ProductName" />
<Button x:Name="btnAddProduct"
Content="Add Product"
Width="100px"
Height="25px"
Command="{Binding AddProductCommand}" />
<Label Content="Selected Product Details"
FontWeight="Bold"
FontSize="16"
Margin="10" />
<TextBox x:Name="txtProductName"
Width="200"
Height="30"
Text="{Binding productName}"
/>
<TextBox x:Name="txtProductPrice"
Width="200"
Height="30"
Text="{Binding productPrice}" />
</StackPanel>
</Grid>
</Window>