dvox
dvox

Reputation: 91

Binding value on custom control with TemplateBinding

I have created a custom control A, with ControlTemplate section, where:

<myOtherControl DataContext="{TemplateBinding ItemsSource}"/>, 

and MyOtherControl has:

<DataGrid ItemsSource={Binding VMDataProperty}/>

In my view I have:

<A ItemsSource="{Binding VMData}"/>

By my opinion this should work, but it doesn't;

Any thoughts?

Edit:

 ViewModelData VMData = new ViewModelData() 
{
    List<Person> VMDataProperty {get; set;}
    string Name { get; set;}
    DateTime DateBuy { get; set;}
    ...
    }

Upvotes: 0

Views: 346

Answers (1)

JSprang
JSprang

Reputation: 12909

It looks to me like you should be setting the DataContext of "A" instead of its ItemsSource.

Upvotes: 2

Related Questions