1

I have within a datagrid the following column. As you can see its a template column that when in display its a label and when in edition mode it becomes a drop down box. The problem I am having is that this specific drop down only contains digits (0,1,2,3) when the user wants to put that row in edition mode to edit that specific cell he has to click precisely on the number otherwise nothing happens. I would like the entire cell when clicked to trigger the edition mode.

How can I achieve this ?

<data:DataGridTemplateColumn Header="Retries" >
                    <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <!--MouseLeftButtonUp="Label_MouseLeftButtonUp"-->
                            <sdk:Label Content="{Binding RetriesWrapper, Mode=OneWay,ValidatesOnDataErrors=True,NotifyOnValidationError=True}" />
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellTemplate>
                    <data:DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <ComboBox ItemsSource="{Binding Source={StaticResource RetriesListItems}, Path=RetriesListItems}" 
                                      SelectedValue="{Binding RetriesWrapper, Mode=TwoWay, ValidatesOnDataErrors=True,NotifyOnValidationError=True}">
                            </ComboBox>
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellEditingTemplate>
                </data:DataGridTemplateColumn>
Stainedart
  • 1,929
  • 4
  • 32
  • 53

1 Answers1

1

try this:

<sdk:Label Content="{Binding RetriesWrapper, Mode=OneWay,ValidatesOnDataErrors=True,NotifyOnValidationError=True},Background=Transparent" />

and this (might be optional):

<ComboBox ItemsSource="{Binding Source={StaticResource RetriesListItems}, Path=RetriesListItems}" 
          SelectedValue="{Binding RetriesWrapper, Mode=TwoWay, ValidatesOnDataErrors=True,NotifyOnValidationError=True}"
          HorizontalAlignment=Stretch
          Background=Transparent>

Edit: The Background=Transparent is a common gotcha, might be the case here as well... see 1) there: What is the worst gotcha in WPF?

Community
  • 1
  • 1
David
  • 6,014
  • 4
  • 39
  • 55
  • Thx David for your reply. I have attempted to add the HorizontalAlignment property first on the combo box as suggested and then on both the label and the combo box but the column still has the same behavior. – Stainedart Mar 19 '12 at 15:52
  • see my edit: I just though about this, maybe it's the same issue you are facing. – David Mar 19 '12 at 15:57
  • You were right it actually was getting me!! Thanks David really appreciate your help! +1 and answer. – Stainedart Mar 19 '12 at 19:13