How can I bind/ connect to different view, that have their own viewModel together?
I have a mainWindow that that contains of to user controls/ views. Each of these have there own viewModel. The first view is like a control panel, with a form to type in input parameters to the application. The other one is a canvas to show the result of the analysis based on the input parameters on the control panel.
Example:
MainWindow:
<StackPanel Orientation="Horizontal" Margin="0,20,0,0">
<local:ControlView />
<local:CanvasView />
</StackPanel>
ControlView:
<StackPanel Orientation="Horizontal">
<Label Content="Length: " Margin="19,0,0,0"/>
<TextBox Margin="3" Width="130" Text="{Binding Path=Box.Length}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Button Margin="10" Content="Draw Canvas" Command="{Binding Path=DrawCanvasCmd}"/>
</StackPanel>
The button triggers a method called DrawCanvas in the ControlViewModel. Then the method is called, I want the canvas to be drawn, based on the input. The drawing of the canvas is done in the CanvasViewModel.
Can anyone see how this can be done? I'm able to draw the canvas using static values in contructor of CanvasViewModel i.e. So _I just need to like send the input parameters from the controlpanel to the canvas.
public void CanvasViewModel()
{
GeometryFigure.length = 120;
}