После нескольких часов поиска я пришел за вашей помощью:
System.Windows.Data Ошибка: 40: Ошибка пути BindingExpression: свойство 'Test' не найдено в 'object'
Я не смог найти, где была моя ошибка привязки ...
В моем MainWindow у меня есть:
<Exec:PriceView Price="{Binding Test}"/>
<TextBlock Text="{Binding Test}"/>
В моем TextBlock свойство Binding with the 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
}
Что я делаю не так?Это исходит из моего свойства зависимости?