如何绑定到内容控件的内容属性?
我创建了自定义控件:
public class CustomControl
{
// Dependency Properties
public int MyProperty
{
get { return (int)GetValue(MyPropertyProperty); }
set { SetValue(MyPropertyProperty, value); }
}
// Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc...
public static readonly DependencyProperty MyPropertyProperty =
DependencyProperty.Register("MyProperty", typeof(int), typeof(MainViewModel), new PropertyMetadata(0));
}
在 ViewModel 中,我创建了此自定义控件类型的属性:
public CustomControl CustomControl { get; set; }
在视图中,我将此属性绑定到内容控件:
<ContentControl x:Name="Custom" Content="{Binding CustomControl}"></ContentControl>
现在如何绑定到内容控件的内容属性?