This is a migrated thread and some comments may be shown as answers.

GridViewRow Control Template

1 Answer 187 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Lee
Top achievements
Rank 1
Lee asked on 21 Dec 2017, 09:05 PM

Hi I was able to create a custom control template for a GridViewCell as follows (perhaps a bad approach?):

                        <Style x:Key="{x:Type telerik:GridViewCell}" TargetType="{x:Type telerik:GridViewCell}" BasedOn="{StaticResource GridViewCellStyle}">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type telerik:GridViewCell}">
                                        <Grid>
                                            <Border x:Name="RowBorder" SnapsToDevicePixels="true" BorderThickness="0,2"  BorderBrush="#222" Background="#222">
                                                <ContentPresenter Content="{TemplateBinding Content}"/> <!--Gets content for GridViewDataColumn DataMemberBinding-->
                                            </Border>
                                            <Border x:Name="AlertBorder" SnapsToDevicePixels="true" BorderThickness="0" Background="#444" Opacity="0"/>
                                        </Grid>

                                          .....Control Template Triggers Data Triggers story board stuff here

    Question is could I do something similar for GridViewRow?????  

                        <Style x:Key="{x:Type telerik:GridViewRow}" TargetType="{x:Type telerik:GridViewRow}" BasedOn="{StaticResource GridViewRowStyle}">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type telerik:GridViewRow}">
                                        <Grid>
                                            <Border x:Name="RowBorder" SnapsToDevicePixels="true" BorderThickness="0,2"  BorderBrush="#222" Background="#222">
                                                             ?????????????Can I present the row cells here with an element and some sort of binding????????????
                                            </Border>
                                            <Border x:Name="AlertBorder" SnapsToDevicePixels="true" BorderThickness="0" Background="#444" Opacity="0"/>
                                        </Grid>

Thanks in advance...

 

 

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 26 Dec 2017, 08:06 AM
Hello Lee,

Yes, you can extract the style of the GridViewRow element and modify it. However, keep in mind that most of the gridview functionality depends on the elements in its Template so it wouldn't be a good idea to completely replace it. Instead, I would recommend you to just slightly change whatever you need to achieve your requirement. Or you can share what you are trying to do and I will think if I can suggest you a more suitable approach. 

Note that you can use the RowStyle property of RadGridView to set the style of the rows.

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GridView
Asked by
Lee
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or