Host Custom User Control In DataGridTemplateColumn

Feb 16, 2011 at 1:54 PM

Hello,

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*" >
                        <my:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate >
                            <Grid>
                                <!-- Custom Control User Rating Stars-->
                                <controls:StarRatingsControl NumberOfStars="5" Value="3" 
                                                             StarForegroundColor="Yellow" StarOutlineColor="Orange" />
                            </Grid>
                            </DataTemplate >
                        </my:DataGridTemplateColumn.CellTemplate>
                    </my:DataGridTemplateColumn>

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

Thanks in advance

Feb 16, 2011 at 2: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">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate >
                            <Grid>
                                <Border Width="30" Height="30" Background="Red"></Border>
                            </Grid>
                        </DataTemplate >
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

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