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

Custom GridViewGroupPanelTemplate

5 Answers 85 Views
GridView
This is a migrated thread and some comments may be shown as answers.
xiaofeng
Top achievements
Rank 1
xiaofeng asked on 07 Mar 2012, 07:44 AM
I write a GroupPanelStyle of GrieView and modify the GridViewGroupPanelTemplate But when I drag a column to the group panel,the message , "Drag a column header and ......",is still there.So how to fix it?
My plan is this:
1.Do not display any message by default
2.If user drag colum to the group panel,it still can work as normal.
Here is the Code
<SolidColorBrush x:Key="GridView_GroupPanelInnerBorder" Color="#FFEFF6FF"/>
   <ControlTemplate x:Key="GridViewGroupPanelTemplate" TargetType="telerik:GridViewGroupPanel">
         <Grid>
            <Grid.ColumnDefinitions>
               <ColumnDefinition Width="*" />
               <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
               <VisualStateManager.VisualStateGroups>
                  <VisualStateGroup x:Name="Grouping">
                     <VisualState x:Name="NoGroups"/>
                     <VisualState x:Name="HasGroups">
                        <Storyboard>
                           <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="panelText">
                              <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="Collapsed"/>
                           </ObjectAnimationUsingKeyFrames>
                           <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="panelTextGrouped">
                              <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="Visible"/>
                           </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                     </VisualState>
                  </VisualStateGroup>
               </VisualStateManager.VisualStateGroups>
 
               <Border BorderBrush="{StaticResource GridView_GroupPanelInnerBorder}" BorderThickness="1" Background="{TemplateBinding Background}">
                  <StackPanel Orientation="Horizontal">
                     <TextBlock x:Name="panelText" FontSize="9.5" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" IsHitTestVisible="False" Margin="{TemplateBinding Padding}" telerik:LocalizationManager.ResourceKey="GridViewGroupPanelText" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                     <TextBlock x:Name="panelTextGrouped" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" IsHitTestVisible="False" Margin="{TemplateBinding Padding}" telerik:LocalizationManager.ResourceKey="GridViewGroupPanelTopTextGrouped" Visibility="Collapsed" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                     <ItemsPresenter VerticalAlignment="Center"/>
                  </StackPanel>
               </Border>
            </Border>
            <my:IscMenu Grid.Row="1" HorizontalAlignment="Right">
               <telerik:RadMenuItem Header="Add"></telerik:RadMenuItem>
               <telerik:RadMenuItem Header="Delete"></telerik:RadMenuItem>
               <telerik:RadMenuItem Header="Modify"></telerik:RadMenuItem>
               <telerik:RadMenuItem Header="Group Add"></telerik:RadMenuItem>
            </my:IscMenu>
         </Grid>
   </ControlTemplate>
   <ItemsPanelTemplate x:Key="GridViewGroupPanelItemsPanelTemplate">
         <StackPanel Orientation="Horizontal" VerticalAlignment="Stretch"/>
   </ItemsPanelTemplate>
   <LinearGradientBrush x:Key="GridView_GroupPanelBackground" EndPoint="0.5,1" StartPoint="0.5,0">
      <GradientStop Color="#FFDFDFDF" Offset="1"/>
      <GradientStop Color="#FFBABABA"/>
   </LinearGradientBrush>
   <SolidColorBrush x:Key="GridView_GroupPanelOuterBorder" Color="#FF848484"/>
       
   <Style x:Key="GridViewGroupPanelStyle1" TargetType="telerik:GridViewGroupPanel">
      <Setter Property="Template" Value="{StaticResource GridViewGroupPanelTemplate}"/>
      <Setter Property="MinHeight" Value="20"/>
      <Setter Property="ItemsPanel" Value="{StaticResource GridViewGroupPanelItemsPanelTemplate}"/>        
      <Setter Property="Margin" Value="0"/>
      <Setter Property="Padding" Value="10,0,3,0"/>
      <Setter Property="Background" Value="{StaticResource GridView_GroupPanelBackground}"/>
      <Setter Property="BorderBrush" Value="{StaticResource GridView_GroupPanelOuterBorder}"/>
      <Setter Property="BorderThickness" Value="0,0,0,1"/>
      <Setter Property="VerticalContentAlignment" Value="Center"/>
      <Setter Property="HorizontalContentAlignment" Value="Left"/>
   </Style>

5 Answers, 1 is accepted

Sort by
0
xiaofeng
Top achievements
Rank 1
answered on 08 Mar 2012, 02:08 AM
Help me
0
Dimitrina
Telerik team
answered on 08 Mar 2012, 09:14 AM
Hello,

 Have you tried to remove this line?

telerik:LocalizationManager.ResourceKey="GridViewGroupPanelText"
All the best,
Didie
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
xiaofeng
Top achievements
Rank 1
answered on 15 Mar 2012, 11:48 AM
OK.It works well now.
But I have another problem.
I inherit the radgridview and set the style,
Iwant to get the menu control in the template,but I did not find any method.
All the method I know will return a null
.So Can I how to get control in the template?

Thank you!
0
Dimitrina
Telerik team
answered on 16 Mar 2012, 12:37 PM
Hello,

 You can use the ChildrenOfType method to find elements inside the GridViewGroupPanel like so:

var result = this.clubsGrid.FindChildByType<GridViewGroupPanel>().ChildrenOfType<TextBlock>();

Greetings,
Didie
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
xiaofeng
Top achievements
Rank 1
answered on 27 Mar 2012, 07:03 AM
Sorry,I am very busy in this time and I leave this problem.
Now,I try your method.And It does not work.
I repeat my work.I Inherit from the RadGridView,named CustomGridView,so I want to get the menu control in the class of
CustomGridView.
Your method work on outside of the gridview.

Thanks .
Tags
GridView
Asked by
xiaofeng
Top achievements
Rank 1
Answers by
xiaofeng
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or