我想弄清楚爲什麼Caliburn.Micro沒有綁定我的Screen DisplayName屬性到窗口標題開箱。Caliburn Mico:屏幕的ActivateItem.DisplayName屬性不會綁定到窗口標題自動
我看了這篇文章: https://stackoverflow.com/a/9072035/2111892 那麼,不應該手動綁定它嗎?
我的導體是這樣的:
[Export(typeof (ShellViewModel))]
public class ShellViewModel : Conductor<Screen>, IHandle<IViewModelMessage>
{
[ImportMany(typeof (IViewModelMessageHandler))]
private IEnumerable<IViewModelMessageHandler> _messageHandlers;
[ImportingConstructor]
public ShellViewModel(IEventAggregator eventAggregator)
{
eventAggregator.Subscribe(this);
}
protected override void OnActivate()
{
var viewModel = IoC.Get<LoginViewModel>();
ActivateItem(viewModel);
}
}
...而我的屏幕正在尋找這樣的:
[Export(typeof(LoginViewModel))]
public class LoginViewModel : Screen
{
[ImportingConstructor]
public LoginViewModel(IEventAggregator eventAggregator, IMessageService messageService, IClient client, IClientReceiver receiver, IClientTransceiver transceiver)
{
DisplayName = "Login";
}
}
難道我犯了一個錯誤還是我理解不正確的東西?
編輯:\
ShellView順便說一句是這樣的:
<UserControl x:Class="Test.Client.Gui.Views.ShellView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="900"
Width="1000">
<Grid VerticalAlignment="Center">
<ContentControl x:Name="ActiveItem" />
</Grid>
</UserControl>
喜歡將其綁定到ActiveItem.DisplayName屬性:)好吧,這就是我想知道的,所以它不會自動爲我做這件事。沒關係,那沒關係,我會手動綁定它:) – Jannik