I have a user control with a property defined as follows:
public partial class ChartEx : UserControl
{
private object _dataSource;
public object DataSource
{
get { return _dataSource; }
set
{
_dataSource = value; //break here
}
}
}
In my xaml, I’m trying to bind it to a collection (from inside data template):
<DataTemplate x:Key="tmplCounter">
<my:ChartEx
DataContext="{Binding Converter={StaticResource convTest}, ConverterParameter='DataContext'}"
DataSource="{Binding Converter={StaticResource convTest}, ConverterParameter='DataSource'}">
</my:ChartEx>
</DataTemplate>
But in debugger I see that value that comes to DataSource setter is of type System.Windows.Data.Binding!
Value converter is never entered with parameter “DataSource”, but for “DataContext” it works perfectly. Converter is there merely for debugging purposes, without it things work same way.
How do I make Binding work for properties I defined?
OK, sorry all, I’m a moron.
Turns out in XAML you can’t bind to “simple” properties. The prop must be a dependency property. Following works: