使用VS2013和Caliburn.Micro 2.0.2
鉴于这个例子:
class MyTestCase(TestCase):
def setUp():
# Flush any cached values
request.bind({})
属性:
似乎在设计时,嵌套视图模型属性被忽略。有没有办法支持这个?
Name
public class NestedViewModel : PropertyChangedBase
{
private string _name;
public string Name
{
get { return _name; }
set
{
_name = value;
NotifyOfPropertyChange(() => Name);
}
}
public NestedViewModel()
{
Name = "Nested";
}
}
绿色标签显示设计器中嵌套视图模型的正确<UserControl
x:Class="WpfApplication1.Views.NestedView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:cal="http://www.caliburnproject.org"
xmlns:viewModels="clr-namespace:WpfApplication1.ViewModels"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=viewModels:NestedViewModel, IsDesignTimeCreatable=True}"
cal:Bind.AtDesignTime="True">
<Grid>
<Label x:Name="Name" FontSize="16" Background="LightGreen"/>
</Grid>
</UserControl>
:
Name
public class ShellViewModel : PropertyChangedBase
{
private string _name;
private NestedViewModel _nestedViewModel;
public string Name
{
get { return _name; }
set
{
_name = value;
NotifyOfPropertyChange(() => Name);
}
}
public NestedViewModel NestedViewModel
{
get { return _nestedViewModel; }
set
{
if (Equals(value, _nestedViewModel)) return;
_nestedViewModel = value;
NotifyOfPropertyChange(() => NestedViewModel);
}
}
public ShellViewModel()
{
NestedViewModel = new NestedViewModel();
Name = "Shell";
}
}
绿色标签应该在设计器中显示嵌套视图模型<UserControl
x:Class="WpfApplication1.Views.ShellView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModels="clr-namespace:WpfApplication1.ViewModels"
xmlns:cal="http://www.caliburnproject.org"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=viewModels:ShellViewModel, IsDesignTimeCreatable=True}"
cal:Bind.AtDesignTime="True">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<ContentControl Grid.Row="0" x:Name="NestedViewModel"/>
<Label Grid.Row="1" x:Name="Name" FontSize="16" Background="RoyalBlue"/>
</Grid>
</UserControl>
属性,而是显示shell视图模型的值:
它在运行时正确绑定: