Hello,
I'm playing around with the Infragistics xamDataGrid. I'd like to display in a "Field" (= Cell) a custom UserControl and have for it the Field's DataContext. Somehow the DataContext is always null :-)
Here is the XAML:
<UserControl.Resources>
<Style x:Key="MyTestUserControl" TargetType="{x:Type igDP:CellValuePresenter}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
<myUC:MyTestUserControl DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="TextBoxField" TargetType="{x:Type igDP:CellValuePresenter}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
<TextBox Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
The DataContext for the TextBoxField works fine, but the DataContext for the MyUserControl doesn't.
Some more XAML where I define the Fields:
<igDP:UnboundField BindingPath="SimpleTestStringToDisplay" Label="UnboundField" >
<igDP:Field.Settings>
<igDP:FieldSettings CellValuePresenterStyle="{StaticResource TextBoxField}" />
</igDP:Field.Settings>
</igDP:UnboundField>
<igDP:UnboundField BindingPath="MyUserControlViewModel" Label="UnboundField (UserControl)">
<igDP:Field.Settings>
<igDP:FieldSettings CellValuePresenterStyle="{StaticResource MyTestUserControl}" />
</igDP:Field.Settings>
</igDP:UnboundField>
Does anyone have an idea what I'm doing wrong?
Thanks!
Cheers, Joseph
EDIT: I also tried something like this, without success:
<myUC:MyUserControl DataContext="{TemplateBinding DataContext}" />