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

How to extend RadGridView Control ?

1 Answer 132 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Nikhil Thaker
Top achievements
Rank 1
Nikhil Thaker asked on 08 Apr 2014, 10:42 AM
Hi,

I have to combine the RadDataPager with RadGridView to avoid structuring RadDataPager every time I use RadgridView.

I have created RadGridViewCustom by inheriting from RadGridView and have tried updating RadGridView template in blend by adding RadDataPager in the same.
I have removed the <VisualStateManager.VisualStateGroups/> (Line No - 23) related lines for better visibility here.

01.<telerik:RadGridView x:Class="SLTelerikGridView.CustomControls.RadGridViewCustom"
06.        mc:Ignorable="d"
07.        d:DesignHeight="300" d:DesignWidth="400"
08.        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
09.                                          
10.        x:Name="rgvCustom"
11.        AutoGenerateColumns="False">
12.    <telerik:RadGridView.Resources>
13.        <SolidColorBrush x:Key="GridView_GroupPanelOuterBorder" Color="#FF848484"/>
14.        <telerik:Office_BlackTheme x:Key="Theme"/>
15.        <telerik:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
16.        <LinearGradientBrush x:Key="Background_Disabled" EndPoint="0.5,1" StartPoint="0.5,0">
17.            <GradientStop Color="#E5000000"/>
18.            <GradientStop Color="#E5000000" Offset="1"/>
19.            <GradientStop Color="#4C000000" Offset="0.5"/>
20.        </LinearGradientBrush>
21.        <ControlTemplate x:Key="RadGridViewTemplate" TargetType="telerik:RadGridView">
22.            <Border x:Name="PART_MasterGridContainer" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
23.                <VisualStateManager.VisualStateGroups/>
24.                <Grid x:Name="HierrarchyBackground" Background="{TemplateBinding Background}">
25.                    <Grid.ColumnDefinitions>
26.                        <ColumnDefinition/>
27.                        <ColumnDefinition x:Name="ScrollBarColumn" MinWidth="0" Width="0"/>
28.                    </Grid.ColumnDefinitions>
29.                    <Grid.RowDefinitions>
30.                        <RowDefinition Height="Auto"/>
31.                        <RowDefinition x:Name="PART_AttachedBehaviorRow" Height="Auto"/>
32.                        <RowDefinition/>
33.                        <RowDefinition x:Name="ScrollBarRow" Height="0" MinHeight="0"/>
34.                        <RowDefinition Height="Auto"/>
35.                    </Grid.RowDefinitions>
36.                    <telerik:GridViewGroupPanel x:Name="PART_GroupPanel" BorderBrush="{StaticResource GridView_GroupPanelOuterBorder}" Background="{TemplateBinding GroupPanelBackground}" Grid.ColumnSpan="2" Foreground="{TemplateBinding GroupPanelForeground}" Grid.Row="0" telerik:StyleManager.Theme="{StaticResource Theme}"/>
37.                    <telerik:GridViewScrollViewer x:Name="PART_ItemsScrollViewer" Background="Transparent" CanContentScroll="True" Grid.ColumnSpan="2" Grid.Row="2" Grid.RowSpan="2" telerik:StyleManager.Theme="{StaticResource Theme}">
38.                        <telerik:GridViewScrollViewer.FooterRow>
39.                            <telerik:GridViewFooterRow x:Name="PART_FooterRow" IndentLevel="{TemplateBinding GroupCount}" telerik:StyleManager.Theme="{StaticResource Theme}"/>
40.                        </telerik:GridViewScrollViewer.FooterRow>
41.                        <telerik:GridViewScrollViewer.HeaderRow>
42.                            <telerik:GridViewHeaderRow x:Name="PART_HeaderRow" IndentLevel="{TemplateBinding GroupCount}" telerik:StyleManager.Theme="{StaticResource Theme}"/>
43.                        </telerik:GridViewScrollViewer.HeaderRow>
44.                        <telerik:GridViewScrollViewer.NewRow>
45.                            <telerik:GridViewNewRow x:Name="PART_AddNewRow" IndentLevel="{TemplateBinding GroupCount}" telerik:StyleManager.Theme="{StaticResource Theme}" Visibility="Collapsed"/>
46.                        </telerik:GridViewScrollViewer.NewRow>
47.                        <telerik:GridViewVirtualizingPanel x:Name="PART_GridViewVirtualizingPanel"/>
48.                    </telerik:GridViewScrollViewer>
49.                    <telerik:ScrollPositionIndicator x:Name="PART_ScrollPositionIndicator" Grid.ColumnSpan="2" ContentTemplate="{TemplateBinding ScrollPositionIndicatorTemplate}" HorizontalAlignment="Right" IsHitTestVisible="False" Margin="0,0,28,0" Grid.Row="2" telerik:StyleManager.Theme="{StaticResource Theme}" Visibility="{Binding IsScrolling, Converter={StaticResource BooleanToVisibilityConverter}, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"/>
50.                    <Border x:Name="PART_FrozenColumnsPreview" Background="#33000000" HorizontalAlignment="Left" Grid.Row="1" Grid.RowSpan="4" Visibility="Collapsed" VerticalAlignment="Stretch" Width="6"/>
51.                    <telerik:GridViewLoadingIndicator x:Name="PART_GridViewLoadingIndicator" Grid.ColumnSpan="2" Grid.RowSpan="4" telerik:StyleManager.Theme="{StaticResource Theme}" Visibility="Collapsed"/>
52.                    <Rectangle x:Name="Background_Disabled" Grid.ColumnSpan="2" Fill="{StaticResource Background_Disabled}" IsHitTestVisible="False" Grid.RowSpan="5" Visibility="Collapsed"/>
53.                    <telerik:RadDataPager x:Name="radDataPager" Grid.Row="4"/>
54.                </Grid>
55.            </Border>
56.        </ControlTemplate>
57.        <SolidColorBrush x:Key="ControlBackground" Color="White"/>
58.        <SolidColorBrush x:Key="ControlOuterBorder" Color="#FF848484"/>
59.        <SolidColorBrush x:Key="ControlForeground" Color="Black"/>
60.        <SolidColorBrush x:Key="Item_AlternateBackground" Color="#FFF4F4F4"/>
61.        <SolidColorBrush x:Key="GridView_GridLinesItemBorder" Color="#FFCBCBCB"/>
62.        <LinearGradientBrush x:Key="GridView_GroupPanelBackground" EndPoint="0.5,1" StartPoint="0.5,0">
63.            <GradientStop Color="#FFDFDFDF" Offset="1"/>
64.            <GradientStop Color="#FFBABABA"/>
65.        </LinearGradientBrush>
66.        <SolidColorBrush x:Key="GridView_GroupPanelForeground" Color="Black"/>
67.        <Style x:Key="RadGridViewStyle1" TargetType="telerik:RadGridView">
68.            <Setter Property="Template" Value="{StaticResource RadGridViewTemplate}"/>
69.            <Setter Property="Background" Value="{StaticResource ControlBackground}"/>
70.            <Setter Property="BorderBrush" Value="{StaticResource ControlOuterBorder}"/>
71.            <Setter Property="Foreground" Value="{StaticResource ControlForeground}"/>
72.            <Setter Property="BorderThickness" Value="1"/>
73.            <Setter Property="AlternateRowBackground" Value="{StaticResource Item_AlternateBackground}"/>
74.            <Setter Property="VerticalGridLinesBrush" Value="{StaticResource GridView_GridLinesItemBorder}"/>
75.            <Setter Property="HorizontalGridLinesBrush" Value="{StaticResource GridView_GridLinesItemBorder}"/>
76.            <Setter Property="GroupPanelBackground" Value="{StaticResource GridView_GroupPanelBackground}"/>
77.            <Setter Property="GroupPanelForeground" Value="{StaticResource GridView_GroupPanelForeground}"/>
78.            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
79.            <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
80.            <Setter Property="VerticalAlignment" Value="Stretch"/>
81.            <Setter Property="HorizontalAlignment" Value="Stretch"/>
82.        </Style>
83.    </telerik:RadGridView.Resources>
84.    <telerik:RadGridView.Style>
85.        <StaticResource ResourceKey="RadGridViewStyle1"/>
86.    </telerik:RadGridView.Style>
87.</telerik:RadGridView>


1. Have I been going the right way?
2. If yes, how to expose DataPager specific properties as it is part of template?
3. If no, what approach I should be taking to achieve the same?

Thanks,
Nikhil


 

1 Answer, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 10 Apr 2014, 10:56 AM
Hello Nikhil,


Looking at the snippet you provided, I suggest that RadGridView is isolated in a single resource dictionary. I'm not able to identify, how you are currently reusing it.

On the other hand, I may suggest you to place RadGridView and RadDataPager in a separate UserControl, without predefining the template of RadGridView and integrating pager within it.
In this way you will get an independent layout that could be reused throughout your application. 


Regards,
Vanya Pavlova
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
GridView
Asked by
Nikhil Thaker
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Share this question
or