【发布时间】:2012-01-19 20:03:17
【问题描述】:
经过几个小时的搜索,我来寻求您的帮助:
System.Windows.Data 错误:40:BindingExpression 路径错误:“测试” 在“对象”上找不到属性
我找不到我的绑定错误在哪里...
在我的主窗口中,我有:
<Exec:PriceView Price="{Binding Test}"/>
<TextBlock Text="{Binding Test}"/>
在我的 TextBlock 上,带有 Test 属性的绑定运行良好。
但对于我的 PriceView 控件,它不是。
PriceView.xaml
<StackPanel>
<TextBlock Text="{Binding Price}" FontSize="26" FontFamily="Arial"/>
</StackPanel>
PriceView.xaml.cs
public partial class PriceView : UserControl
{
public PriceView()
{
this.InitializeComponent();
this.DataContext = this;
}
#region Dependency Property
public static readonly DependencyProperty PriceProperty = DependencyProperty.Register("Price", typeof(float), typeof(PriceView));
public float Price
{
get { return (float)GetValue(PriceProperty); }
set { SetValue(PriceProperty, value); }
}
#endregion
}
我做错了什么? 这是来自我的依赖属性吗?
【问题讨论】:
标签: c# wpf silverlight xaml data-binding