是否有关于将AvalonDock与Caliburn Micro MVVM一起使用的博客或文章?谷歌搜索时找不到多少
http://avalondock.codeplex.com/
编辑:得到了投票,所以为什么不用最终解决方案更新.完整代码可以在这里找到
https://github.com/AndersMalmgren/FreePIE
大多数与avalon相关的代码都可以在这里找到
https://github.com/AndersMalmgren/FreePIE/blob/master/FreePIE.GUI/Shells/MainShellView.xaml
Sam回答后更新
为了使Caliburn成功,需要做的非常非常少.首先实现一个LayoutItemTemplateSelector
public class AutobinderTemplateSelector : DataTemplateSelector
{
public DataTemplate Template { get; set; }
public override DataTemplate SelectTemplate(object item, DependencyObject container)
{
return Template;
}
}
Run Code Online (Sandbox Code Playgroud)
并将其与内容控件和Caliburns View.Model附加机制一起使用
<xcad:DockingManager.LayoutItemTemplateSelector>
<avalonDock1:AutobinderTemplateSelector>
<avalonDock1:AutobinderTemplateSelector.Template>
<DataTemplate>
<ContentControl cal:View.Model="{Binding . }" IsTabStop="False" />
</DataTemplate>
</avalonDock1:AutobinderTemplateSelector.Template>
</avalonDock1:AutobinderTemplateSelector>
</xcad:DockingManager.LayoutItemTemplateSelector>
Run Code Online (Sandbox Code Playgroud) 请考虑以下样式:
<Window.Resources>
<Style x:Key="NumberButton" TargetType="Button">
<Setter Property="Width" Value="Auto"/>
<Setter Property="Height" Value="Auto"/>
<Setter Property="Margin" Value="2"/>
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<Label Content="{Binding}" FontSize="20" FontFamily="Consolas"/>
</DataTemplate>
</Setter.Value>
</Setter>
<EventSetter Event="Click" Handler="OnClicked"/>
</Style>
</Window.Resources>
Run Code Online (Sandbox Code Playgroud)
我的目标是能够创建多个按钮,每个按钮代表一个0-9的数字.例如,这是数字0的按钮:
<Button Grid.Row="3" Grid.Column="1" Style="{StaticResource NumberButton}" Content="0"/>
Run Code Online (Sandbox Code Playgroud)
我对DataContext如何工作的理解是,如果你没有在XAML中显式设置它,它应该是NULL,它指示绑定使用父的DataContext.这是可传递的,因此它将继续向上移动每个父级,直到找到要使用的显式设置的DataContext.
然而,我对我的绑定如何映射到Content属性感到困惑.我知道ContentControl的默认属性是Content财产,但我从来没有明确设置DataContext上<Button>的元素.对我来说,这意味着Button的DataContext为NULL,因此无法找到要显示的值.
有人可以解释当我没有设置Button时如何引用Button的DataContext?