I have a custom usercontrol (ChartControl
) that I use within my WPF app (MainApp
) and which I render as follows:
<ContentControl Grid.Row="1" Content="{Binding ChartControl, Mode=OneWay}" />
Upon starting MainApp
the following are executed in the given order:
MainApp View MainApp ViewModel ChartControl ViewModel ChartControl View
I instantiate the ChartControl
ViewModel from within the constructor of my MainApp
ViewModel. The problem is that after instantiating the ChartControl
ViewModel I also need to call a method of ChartControl
from within MainApp
.
The problem I am having is that I need the ChartControl
view to be rendered (have its InitializeComponent
executed) before I call the method as part of its viewmodel.
I thought one solution could be to notify the view model from the view when it is fully instantiated and set up. Is that a viable solution and if yes how would I do that?
In summary, I need the view to be fully set up before invoking a method of the matching viewmodel. The problem I am having is that in this case the view model is instantiated first and only then is the view rendered.
Any ideas?
Thanks
InitializeComponent
executed? What are you trying to do actually? This sounds like a xy problem for me. – Ordway