Question

I have this Caliburn.Micro sample project I'm putting together and I am having trouble with the convention-based bindings with nested views/viewmodels.

As an example, let's say I have a shell view, ShellView, backed by ShellViewModel which is a screen conductor.

I have a content control in the ShellView bound to ActiveItem (using the x:Name convention), and the ActiveItem is of type EmployeeListViewModel, so the resulting view is EmployeeListView. Nested in this view is an EmployeeDetailsView backed by an EmployeesDetailsViewModel which is bound to the selected item in EmployeeListViewModel.

This works fine, except that in EmployeeDetailsView I can't bind things like text boxes and buttons using the Caliburn conventions. This works fine:

<TextBox Text="{Binding EmployeeID}" />

but neither of these lines work:

<TextBox x:Name="EmployeeID" />
<Button x:Name="ClickMethod" />

The text box text binding isn't a big deal but the automatic button method hookup is one of the coolest things about Caliburn.Micro, but it doesn't seem to work in nested views.

Any ideas?

Was it helpful?

Solution

I have a feeling that you when you are binding the EmployeesDetailsViewModel (SelectedItem ) to the EmployeesDetailsView that you are doing it manually. CM isn't wiring things up at that point. Can you post the xaml and some cs for the SelectedItem binding? Did you try

<MyUc:EmployeesDetailsView x:Name="SelectedEmployee" />

And hang a SelectedEmployee off the EmployeeListViewModel?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top