WPF Datatemplate w/ Multiple DataConrtexts

B

Bill McCormick

I've got two huge books on WPF and can't find a solution for this:

I'm using the DataGrid from the toolkit where I set its ItemSource in code.
In the DataGrid.RowDetailsTemplate I have a couple of controls that need to
have binding's to a different Datacontext than the main Datagrid. I need to
know how to set the DataContext for the StackPanel that contains the
templated controls. The tree looks something like this:

<DataGrid Name="Foo">
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<StackPanel>
<StackPanel Name="Bar">
</StackPanel>
</StackPanel>
</DataTemplate>
</DataGrid.RowDetailsTemplate>
</DataGrid>


and somewhere in the code I have:

MyBadAssGrid.ItemsSource= Db.FooList.OrderBy(f => f.FooName)


Anyone??

TIA, Bill
 
B

Bill McCormick

I've got two huge books on WPF and can't find a solution for this:

I'm using the DataGrid from the toolkit where I set its ItemSource in
code. In the DataGrid.RowDetailsTemplate I have a couple of controls
that need to have binding's to a different Datacontext than the main
Datagrid. I need to know how to set the DataContext for the StackPanel
that contains the templated controls. The tree looks something like this:

<DataGrid Name="Foo">
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<StackPanel>
<StackPanel Name="Bar">
</StackPanel>
</StackPanel>
</DataTemplate>
</DataGrid.RowDetailsTemplate>
</DataGrid>


and somewhere in the code I have:

MyBadAssGrid.ItemsSource= Db.FooList.OrderBy(f => f.FooName)
Sorry that would be
Foo.ItemsSource = Db.FooList.OrderBy(f => f.FooName)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top