Reputation: 307
This is probably a very simple question, but at this time I have myself so confused I can't see the answer. Simply put, I have a window that contains a content control. I'm using Caliburn.Micro's conventions to "locate" the view.
The window looks like this:
<Window x:Class="Views.MainWindowView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<TextBox/>
<ContentControl x:Name="MyViewModel" Height="Auto" Background="Blue"/>
</Grid>
</Window>
The view itself is successfully found, and the screen displays as I expected. However, MyViewModel needs to make a service call to get information based on what is typed into the text box.
So, what I can't seem to figure out is how one would pass that information from the text box to the view model. I've thought of several options, but they all seem to be too much work which makes me think that I'm missing something simple.
Thanks a lot
Upvotes: 1
Views: 1957
Reputation: 9478
Like you said there are a number of things you can do:
You could expose a property on MyViewModel
and set it within
MainWindowView
.
You could use the EventAgregator
, publish an event from the
MainWindowView
and subscribe to that event from MyViewModel
.
Using MEF you could inject a shared resource between the two
ViewModels, set it in MainWindowViewModel
, and be able to access it
from MyViewModel
.
Upvotes: 2