HyperlinkButton for xAxis Labels

2 posts, 0 answers
  1. Tyler
    Tyler avatar
    32 posts
    Member since:
    Jun 2011

    Posted 27 Sep 2011 Link to this post

    How can I change my xAxis labels to HyperLinkButtons ?
  2. Sia
    Admin
    Sia avatar
    745 posts

    Posted 30 Sep 2011 Link to this post

    Hi Tyler,

    You need to set custom AxisLabel2D style which can be applied implicitly to all labels on your axes. There add the HyperlinkButton:
    <telerik:LabelFormatConverter x:Key="labelFormatConverter" />
    <Style TargetType="telerik:AxisLabel2D">
        <Setter  Property="Foreground" Value="Red" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="VerticalAlignment" Value="Top" />
        <Setter Property="ItemLabelStyle">
            <Setter.Value>
                <Style TargetType="TextBlock">
                    <Setter Property="TextAlignment" Value="Center" />
                    <Setter Property="Padding" Value="1" />
                </Style>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="telerik:AxisLabel2D">
                    <telerik:LayoutTransformControl x:Name="PART_LayoutTransformControl"
                                                    VerticalAlignment="{TemplateBinding VerticalAlignment}"
                                                    HorizontalAlignment="{TemplateBinding HorizontalAlignment}">
                        <telerik:LayoutTransformControl.Content>
                            <HyperlinkButton>
                                <TextBlock Style="{TemplateBinding ItemLabelStyle}"
                                        Text="{Binding Converter={StaticResource labelFormatConverter}}" />
                            </HyperlinkButton>
                        </telerik:LayoutTransformControl.Content>
                        <telerik:LayoutTransformControl.LayoutTransform>
                            <RotateTransform x:Name="PART_RotateTransform" />
                        </telerik:LayoutTransformControl.LayoutTransform>
                    </telerik:LayoutTransformControl>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    Best wishes,
    Sia
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top