I need some help in defining a ControlTemplate for a CellValuePresenter in XAML. Normally control templates make use of a content presenter of some sort ... what would I use for the cell value presenter? Basically I have a scenario where a particular field is has an EditorType defined (say a ComboEditor) but in some instances I don't want to show any editor at all - just a blank cell. Other times I want to show the combo editor as defined.
I've tried this so far:
<Style TargetType="{x:Type igDP:CellValuePresenter}" x:Key="claimCellGrayedOut">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
<Border BorderBrush="{DynamicResource WPFGridCellBorder}" BorderThickness="0.5,0,0.5,0">
<ContentPresenter x:Name="cellContent" Margin="0,2,0,2">
<ContentPresenter.Visibility>
<Binding Path="Record.Index" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type igDP:DataRecordCellArea}}">
<Binding.Converter>
<local:IndexToVisibilityConverter />
</Binding.Converter>
</Binding>
</ContentPresenter.Visibility>
</ContentPresenter>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Thanks, i resolved it.
Hello dkofoed,
I am just checking have you been able to resolve your issue? If you still need any assistance on the matter do not hesitate to ask.
I have been looking into your questions and I am not sure that I understand your scenario. Would you please provide me with some additional details if you have a collection bound to your unbound field and if you want the conversion of the editor to be based on the value of the cell from the unbound column itself, or from the values of another cells of the current record. Would you please modify the sample that we have discussed in order to represent your scenario, so I can be sure that we are working on the same functionality.
Thanks in advance.
I figured out how to find the data template resources using a multiconverter, passing in the style as one of the parameters ...
My problem now is binding. The value in my data template is not showing up. The control inside the data template is a DateTimeEditor (for example), and I need to bind it's value to the data item of the unbound field.
How would i accomplish that? Binding to the CellValuePresenter's Value property does not work.
OK, I think I see how that might be possible ...
But the sample in the topic you mentioned extracts the resources from a converter using Application.Current. In my case, I do not have access to put any data template resources within the App.Xaml file - the templates would need to go in the window resources.
How could I find the resources from code in that case?