Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a problem with a user control in a DataGrid.
I have add the usercontrol to the DataGridTemplateColumn, like this

XML
<DataGridTemplateColumn Header="Test" Width="250" x:Name="ColTest" >
  <DataGridTemplateColumn.CellTemplate>
    <DataTemplate x:Name="ColTestDataTemplate">
      <SpecialTextbox Name="foobar" Text="Incorrect width" />
    </DataTemplate>
  </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>


The usercontrol is also shown, unfortunately the width of the usercontrol is not the width of the column.

I have been looking for a few hours, but unfortunately found nothing.
Maybe someone knows a solution

Thanks and sorry for my bad english
Posted

Try setting HorizontalAlignment[^] to Stretch[^] for the UserControl ... ( and possibly check that the width is not set in xaml for the UserControl )

Regards
Espen Harlinn
 
Share this answer
 
v2
Comments
Nish Nishant 7-Feb-11 17:06pm    
Since he wants the width to fit the parent, he probably needs to try setting the HorizontalAlignment to Stretch.
Espen Harlinn 7-Feb-11 17:16pm    
Oops, fixed it, thanks :)
Nish Nishant 7-Feb-11 17:19pm    
No problem. I voted it 5 as it's a good suggestion, although we don't know at the moment if it will solve the OP's problem.
Espen Harlinn 7-Feb-11 17:33pm    
Well, thank you Nishant :)
Sergey Alexandrovich Kryukov 7-Feb-11 20:03pm    
My 5. Layout can be tricky but always solvable due to sufficient flexibility of WPF :-)
--SA
thanks, the problem was not the usercontrol, but an other element on the control.
for the next time i know it
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900