Caliburn: how to bind hosted controls to ViewModel properties
-
28-10-2019 - |
Question
I created a control which is hosting two content controls. I would like Caliburn to resolve the View/ViewModel for me but Caliburn ignores the hosted/inner ContentControls with the name SignalGenerator (see below). Any idea how to get around that problem?
<cc:HorizontalSplitterLayoutControl >
<cc:HorizontalSplitterLayoutControl.UpperContent>
<Label Content="Blockdiagram" />
</cc:HorizontalSplitterLayoutControl.UpperContent>
<cc:HorizontalSplitterLayoutControl.LowerContent>
<ContentControl x:Name="SignalGenerator"/>
</cc:HorizontalSplitterLayoutControl.LowerContent>
</cc:HorizontalSplitterLayoutControl>
Solution
I haven't tried myself, but you should be able to do something like the following:
<ContentControl x:Name="SignalGenerator" cal:View.Model="{Binding}" />
OTHER TIPS
In another project I had to do it like this:
<ContentControl cal:View.Model="{Binding SignalGenerator}" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow