How do I make the icon on the Accordion stay at the end with the same direction?

1 Answer 48 Views
Accordion
Rodrigo
Top achievements
Rank 1
Rodrigo asked on 20 Sep 2024, 07:41 PM

Hi!

I need help.

I would like the icon to be at the end and keep the same direction as in the image
> closed
v open

 

In this example below it is at the end but changes direction.

https://www.telerik.com/forums/icon-in-accordion-header

Regards,

Rodrigo.

1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 25 Sep 2024, 01:44 PM

Hello Rodrigo,

The easiest way to achieve it is to leave the IndicatorLocation to "Start" as in this case the icon is not changed, and modify the HeaderControlTemplate where you can manually set the indicator position without taking into account the IndicatorLocation property. 

Here is the needed approach:

1. Add the following ControlTemplate to the page's resources:

 

  <telerikExpander:InverseThicknessConverter x:Key="InverseThicknessConverter" />
  
  <ControlTemplate x:Key="AccordionItemHeader_ControlTemplate">
      <telerik:RadBorder BackgroundColor="{TemplateBinding BackgroundColor}"
                               Background="{TemplateBinding Background}"
                               BorderColor="{TemplateBinding BorderColor}"
                               BorderBrush="{TemplateBinding BorderBrush}"
                               BorderThickness="{TemplateBinding BorderThickness}"
                               CornerRadius="{TemplateBinding CornerRadius}"
                               Padding="{TemplateBinding ContentPadding}"
                               Margin="{TemplateBinding Padding, Converter={StaticResource InverseThicknessConverter}}">
          <telerik:RadBorder.GestureRecognizers>
              <TapGestureRecognizer Command="{TemplateBinding ToggleExpandCommand}" />
          </telerik:RadBorder.GestureRecognizers>
          <Grid ColumnDefinitions="Auto, *, Auto">
              <telerikExpander:ExpandCollapseIndicator x:Name="PART_ExpandCollapseIndicator"
                                          Text="{TemplateBinding IndicatorText}"
                                          Margin="{TemplateBinding IndicatorMargin}"
                                          IsExpanded="{TemplateBinding IsExpanded}"
                                          IsAnimationEnabled="{TemplateBinding IsAnimationEnabled}"
                                          FontFamily="{TemplateBinding IndicatorFontFamily}"
                                          TextColor="Black"
                                          IndicatorLocation="{TemplateBinding IndicatorLocation}"
                                          IndicatorAnimationDuration="{TemplateBinding IndicatorAnimationDuration}"
                                          IndicatorAnimationEasing="{TemplateBinding IndicatorAnimationEasing}"
                                          Grid.Column="2"
                                          FontSize="{TemplateBinding IndicatorFontSize}"
                                          VerticalOptions="Center"
                                          AutomationId="RadAccordionExpandCollapseIndicator" />
              <ContentPresenter Grid.Column="1" AutomationId="RadAccordionHeader" />
          </Grid>
      </telerik:RadBorder>
  </ControlTemplate>

 

2. Apply it to the AccordionItemHeader either directly as in the referenced link or through style, like this:

 

<telerik:AccordionItem HeaderText="Profile">
    <telerik:AccordionItem.Resources>
        <Style TargetType="telerik:AccordionItemHeader">
            <Setter Property="ControlTemplate" Value="{StaticResource AccordionItemHeader_ControlTemplate}" />
        </Style>
    </telerik:AccordionItem.Resources>
    <telerik:AccordionItem.Content>
        <Label Text="John Smith" Margin="8" />
    </telerik:AccordionItem.Content>
</telerik:AccordionItem>

Please give it a try and let me know if you have any additional concerns or questions on this.

Regards,
Yana
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Rodrigo
Top achievements
Rank 1
commented on 25 Sep 2024, 05:48 PM

Hi!

 

Thanks! It worked!

 

Regards,

Rodrigo.

Tags
Accordion
Asked by
Rodrigo
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or