I'm having serious difficulties with grid's combobox
column binding.
I have a grid
in which each row represent an item. My item has the property "NumberPhase"
.
I want to bind the ItemsSource
of a certain combobox
column. The list of values is supposed to be different for different rows.
When binding to my item's property only, it works fine:
<telerik:gridviewcomboboxcolumn x:name="sensorCountColumn" edittriggers="CellClick"
width="*" itemssourcebinding="NumberPhase" datamemberbinding="{Binding FactorType, Converter={StaticResource enumDescriptionConverter}, ConverterParameter=FACTOR_TYPE}"
isreadonlybinding="{Binding IsThreePhaseParentAndNotDeleted, Converter={StaticResource invertBooleanConverter}}"
editorstyle="{StaticResource radComboBoxStyle}">
But, I want to add dependency
in another variable (which is not of the item bounded to this grid's row
). So I tried something like this:
<telerik:gridviewcomboboxcolumn x:name="sensorCountColumn" edittriggers="CellClick"
width="*" datamemberbinding="{Binding FactorType, Converter={StaticResource enumDescriptionConverter}, ConverterParameter=FACTOR_TYPE}"
isreadonlybinding="{Binding IsThreePhaseParentAndNotDeleted, Converter={StaticResource invertBooleanConverter}}"
editorstyle="{StaticResource radComboBoxStyle}">
<telerik:GridViewComboBoxColumn.ItemsSource>
<MultiBinding diagnostics:PresentationTraceSources.TraceLevel="High" Converter="{StaticResource sensorCountConverter}">
<Binding Path="NumberPhase" />
<Binding Path="Data.PanelConfig.ID" Source="{StaticResource editedLocation}" />
</MultiBinding>
</telerik:GridViewComboBoxColumn.ItemsSource>
...
</telerik:gridviewcomboboxcolumn>
When running that, my converter got the first value (NumberPhase) as DependencyProperty
. UnsetValue
. The second value is just fine.
I thought maybe I should change the tag name to ItemsSourceBinding
instead of ItemsSource
(because in the first example I used that name for one variable and it worked).
So I tried something like this:
<telerik:gridviewcomboboxcolumn x:name="sensorCountColumn" edittriggers="CellClick"
width="*" datamemberbinding="{Binding FactorType, Converter={StaticResource enumDescriptionConverter}, ConverterParameter=FACTOR_TYPE}"
isreadonlybinding="{Binding IsThreePhaseParentAndNotDeleted, Converter={StaticResource invertBooleanConverter}}"
editorstyle="{StaticResource radComboBoxStyle}">
<telerik:GridViewComboBoxColumn.ItemsSourceBinding>
<MultiBinding diagnostics:PresentationTraceSources.TraceLevel="High" Converter="{StaticResource sensorCountConverter}">
<Binding Path="NumberPhase" />
<Binding Path="Data.PanelConfig.ID" Source="{StaticResource editedLocation}" />
</MultiBinding>
</telerik:GridViewComboBoxColumn.ItemsSourceBinding>
</telerik:gridviewcomboboxcolumn>
The result was an exception
thrown with the message:
A 'MultiBinding' cannot be set on the 'ItemsSourceBinding' property of type 'GridViewComboBoxColumn'. A 'MultiBinding' can only be set on a DependencyProperty of a DependencyObject.
I've also read about the proxy pattern, but I think I can't use it in my case, because when I try to place it inside the grid I get the following message:
The type 'RadGridView' does not support direct content. I cannot place it outside because then I'll have a problem to bind to the proper row's item of the grid.
Any suggestion will be appreciated!!