Hi,
I'm trying to use a MultivalueConverter in a XamDataGrid. I keep getting an error in the converter - the first value doesn't get set (the second one (ItemListLanguage) is fine.) The converter itself works fine because I'm already using it in a TreeView control elsewhere.
Below is my code. I've tried various things for the RelativeSource (i.e. nothing, TemplatedParent, and now Self) and I always get the same error - the value for "DisplayTitle" just doesn't get passed to the converter. I've been playing with this a little too long and now I'm running in circles. I get the feeling it's something really stupid that I'm missing from working on it too long. :) Here's the code (sorry for the formatting, I don't know how to post it in "pretty mode"):
<igDP:XamDataGrid x:Name="SearchResultsGrid" Grid.Row="1" GroupByAreaLocation="None" SizeChanged="SearchResultsGrid_SizeChanged" RecordsInViewChanged="SearchResultsGrid_RecordsInViewChanged" RecordActivated="SearchResultsGrid_RecordActivated" > <igDP:XamDataGrid.Resources> <Style x:Key="DisplayTitleStyle" TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <TextBlock> <TextBlock.Text> <MultiBinding Converter="{StaticResource MultilingualStringConverter}"> <MultiBinding.Bindings> <Binding Path="DisplayTitle" RelativeSource="{RelativeSource Self}"></Binding> <Binding Path="ItemListLanguage"> <Binding.RelativeSource> <RelativeSource Mode="FindAncestor" AncestorType="{x:Type local:ClassificationSearchControl}" /> </Binding.RelativeSource> </Binding> </MultiBinding.Bindings> </MultiBinding> </TextBlock.Text> </TextBlock> </ControlTemplate> </Setter.Value> </Setter> </Style> </igDP:XamDataGrid.Resources> <igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings DataRecordSizingMode="SizableSynchronized" AutoGenerateFields="False" ExpansionIndicatorDisplayMode="Never" RecordSelectorLocation="None" SelectionTypeField="Single" SelectionTypeCell="Single" SelectionTypeRecord="Single" > </igDP:FieldLayoutSettings> </igDP:XamDataGrid.FieldLayoutSettings> <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:FieldLayout.SortedFields> <igDP:FieldSortDescription FieldName="Code" Direction="Ascending" > </igDP:FieldSortDescription> </igDP:FieldLayout.SortedFields> <igDP:FieldLayout.FieldSettings> <igDP:FieldSettings AllowEdit="False" AllowResize="True" CellClickAction="SelectRecord" /> </igDP:FieldLayout.FieldSettings> <igDP:FieldLayout.Fields> <igDP:Field x:Name="CodeField" Name="Code" Label="{Binding CodeColumnHeader}" > <igDP:Field.Settings> <igDP:FieldSettings LabelTextAlignment="Left" /> </igDP:Field.Settings> </igDP:Field> <igDP:Field x:Name="TitleField" Name="DisplayTitle" DataType="{x:Type sys:Object}" IsScrollTipField="True"> <igDP:Field.Settings> <igDP:FieldSettings EditAsType="{x:Type sys:String}" CellValuePresenterStyle="{StaticResource DisplayTitleStyle}" /> </igDP:Field.Settings> </igDP:Field> </igDP:FieldLayout.Fields> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts> </igDP:XamDataGrid>
Any idea? I've browsed around on the forum and experimented a bit with the examples I found, to no avail.
Thanks,Michel
That worked, thanks! I don't have much experience with templating yet, so if I hadn't asked I think I'd still be looking.
Now I just need to make it look pretty, but that's another story. :)
Thanks!Michel
So this is the custom CVP style for the DisplayTitle Field, right? If so then what you probably want to do is to use a Binding whose path is Value and relativesource is TemplatedParent - the Value of the CVP for the cels in that field will be the DisplayTitle for the associated record.