Caliburn Micro依赖项依赖绑定

时间:2019-04-10 11:24:55

标签: data-binding caliburn.micro

我有一个带有以下DP的自定义控件:

public FrameworkElement NoResultContent
{
    get { return (FrameworkElement)GetValue(NoResultContentProperty); }
    set { SetValue(NoResultContentProperty, value); }
}

public static readonly DependencyProperty NoResultContentProperty =
    DependencyProperty.Register("NoResultContent", typeof(FrameworkElement), typeof(AdvancedAutoCompleteBox), new PropertyMetadata(null));

我的自定义控件的ControlTemplate在ContentControl中显示此DP:

<ContentControl Content="{TemplateBinding NoResultContent}" />

它用于提供任意功能的视图:

<Controls:AdvancedAutoCompleteBox
    x:Name="Box"    
    ItemsSource="{Binding Persons}"    
    SelectedItem="{Binding SelectedPerson}"
    Watermark="Search here">
    <Controls:AdvancedAutoCompleteBox.NoResultContent>
        <StackPanel>
            <Button
                Content="Add by ICommand"
                Command="{Binding AddPerson}" />
            <Button
                x:Name="AddPerson"
                Content="Add by Caliburn" />
        </StackPanel>
    </Controls:AdvancedAutoCompleteBox.NoResultContent>
</Controls:AdvancedAutoCompleteBox>

将命令绑定到ICommand可以正常工作。购买为什么它不能与Caliburn.Micro一起使用? 我还尝试通过cal:Bind.Model

手动将上下文附加到第二个Button

0 个答案:

没有答案