Custom GridViewGroupPanelTemplate

6 posts, 0 answers
  1. xiaofeng
    xiaofeng avatar
    60 posts
    Member since:
    Jun 2008

    Posted 07 Mar 2012 Link to this post

    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>
  2. xiaofeng
    xiaofeng avatar
    60 posts
    Member since:
    Jun 2008

    Posted 07 Mar 2012 Link to this post

    Help me
  3. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 08 Mar 2012 Link to this post

    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 >>
  4. xiaofeng
    xiaofeng avatar
    60 posts
    Member since:
    Jun 2008

    Posted 15 Mar 2012 Link to this post

    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!
  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 16 Mar 2012 Link to this post

    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 >>
  6. xiaofeng
    xiaofeng avatar
    60 posts
    Member since:
    Jun 2008

    Posted 27 Mar 2012 Link to this post

    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 .
Back to Top