Host Custom User Control In DataGridTemplateColumn

Feb 16, 2011 at 2:54 PM


I am trying to make a custom DataGrid Column Cell. I want to host one of the user controls inside DataGrid Cell, but for some reason it does not appear. I shows regulary outside of the datagrid.

This is code :

 <my:DataGridTemplateColumn Header="{StaticResource HeaderRating}" Width=".30*" >
                            <DataTemplate >
                                <!-- Custom Control User Rating Stars-->
                                <controls:StarRatingsControl NumberOfStars="5" Value="3" 
                                                             StarForegroundColor="Yellow" StarOutlineColor="Orange" />
                            </DataTemplate >

If someone can tell , what am i doing wrong? (Problem remain)

Thanks in advance

Feb 16, 2011 at 3:58 PM

What exactly do you mean by "I shows regulary outside of the datagrid."? The code you posted should actually work. Have you tried using another control? Are you sure the problem is not located in the UserContol (RenderTransforms or anything that could relocate your control)? 

                <DataGridTemplateColumn Width="Auto">
                        <DataTemplate >
                                <Border Width="30" Height="30" Background="Red"></Border>
                        </DataTemplate >

Would this show up correctly? This is working just fine for me.