开发者

Caliburn.Micro convention-based bindings not working in nested views?

开发者 https://www.devze.com 2023-01-25 21:32 出处:网络
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.

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 EmployeesD开发者_如何学JAVAetailsViewModel 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?


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号