在我的WPF应用程序中,我创建了自己的控件并希望绑定到其中的属性。这就是我目前所尝试的:
public partial class BreadcrumbContainer : Grid
{
public static readonly DependencyProperty TestProperty =
DependencyProperty.Register(nameof(Test), typeof(string), typeof(BreadcrumbContainer), new PropertyMetadata(string.Empty));
public string Test
{
get { return (string)GetValue(TestProperty); }
set { SetValue(TestProperty, value); Refresh(); }
}
public BreadcrumbContainer()
{
InitializeComponent();
}
private void Refresh()
{
// never gets called
}
}
我试着和我的
Test
<controls:BreadcrumbContainer Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" Test="{Binding SearchMessage}"/>
在我的视图模型中,我有一个属性
SearchMessage
. 我所有的其他绑定都在工作,所以这一定是我在工作中做错了什么
BreadcrumbContainer