I've recently moved from WinForms to WPF and I'm finding it hard to separate ViewModel and View. I'm designing the entire view in the ViewModel. Eventhough it works, I'm sure it is not the right way.
Is there anyway I can separate View and ViewModel without modifying much? I've did some research on it, but it wasn't that helpful.
EDIT
XAML
<Window x:Class="PackageDeliveryTool.FolderCheck"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Main Window" Height="350" Width="640" ResizeMode="NoResize" ShowInTaskbar="False" Topmost="True" Cursor="Arrow" Closing="Window_Closing">
<!-- From here is the XAML view code which includes button/Grid/StackPanel etc -->
</Window>
And I have separate CS file for model. which has properties and propertyChanged Events.
This is XAML.Cs file of particular Window. has actions and and Model Object(s),
public partial class CopyMessageWindow : Window
{
Model m = new Model("someValue");
public CopyMessageWindow()
{
InitializeComponent();
}
public void StartButton_Click(object sender, RoutedEventArgs e){
//Some code goes here uses Model instance
}
public void OtherLogicMethod(int val){
//Some other logic not related to UI, but to Background program. Also uses Model Instance
}
private void CancelButton_Click(object sender, RoutedEventArgs e)
{
//When cancel button is clicked, uses Model instance
}
}
EDITx2
I've already written much code. I need a more simplistic way of separating view and ViewModel.